sh_eth: re-enable-E-MAC interrupts in sh_eth_set_ringparam()
[linux/fpc-iii.git] / net / wireless / ocb.c
blobe64dbf16330c4f52f89146bc3e9096958a4303ed
1 /*
2 * OCB mode implementation
4 * Copyright: (c) 2014 Czech Technical University in Prague
5 * (c) 2014 Volkswagen Group Research
6 * Author: Rostislav Lisovy <rostislav.lisovy@fel.cvut.cz>
7 * Funded by: Volkswagen Group Research
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
14 #include <linux/ieee80211.h>
15 #include <net/cfg80211.h>
16 #include "nl80211.h"
17 #include "core.h"
18 #include "rdev-ops.h"
20 int __cfg80211_join_ocb(struct cfg80211_registered_device *rdev,
21 struct net_device *dev,
22 struct ocb_setup *setup)
24 struct wireless_dev *wdev = dev->ieee80211_ptr;
25 int err;
27 ASSERT_WDEV_LOCK(wdev);
29 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_OCB)
30 return -EOPNOTSUPP;
32 if (!rdev->ops->join_ocb)
33 return -EOPNOTSUPP;
35 if (WARN_ON(!setup->chandef.chan))
36 return -EINVAL;
38 err = rdev_join_ocb(rdev, dev, setup);
39 if (!err)
40 wdev->chandef = setup->chandef;
42 return err;
45 int cfg80211_join_ocb(struct cfg80211_registered_device *rdev,
46 struct net_device *dev,
47 struct ocb_setup *setup)
49 struct wireless_dev *wdev = dev->ieee80211_ptr;
50 int err;
52 wdev_lock(wdev);
53 err = __cfg80211_join_ocb(rdev, dev, setup);
54 wdev_unlock(wdev);
56 return err;
59 int __cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,
60 struct net_device *dev)
62 struct wireless_dev *wdev = dev->ieee80211_ptr;
63 int err;
65 ASSERT_WDEV_LOCK(wdev);
67 if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_OCB)
68 return -EOPNOTSUPP;
70 if (!rdev->ops->leave_ocb)
71 return -EOPNOTSUPP;
73 err = rdev_leave_ocb(rdev, dev);
74 if (!err)
75 memset(&wdev->chandef, 0, sizeof(wdev->chandef));
77 return err;
80 int cfg80211_leave_ocb(struct cfg80211_registered_device *rdev,
81 struct net_device *dev)
83 struct wireless_dev *wdev = dev->ieee80211_ptr;
84 int err;
86 wdev_lock(wdev);
87 err = __cfg80211_leave_ocb(rdev, dev);
88 wdev_unlock(wdev);
90 return err;