diff options
author | Michal Kazior <michal.kazior@tieto.com> | 2012-06-29 06:46:56 -0400 |
---|---|---|
committer | Johannes Berg <johannes.berg@intel.com> | 2012-06-29 07:39:14 -0400 |
commit | 60771780c27cbc93d0b78da0c7fd7a8a540b029e (patch) | |
tree | 207f080b796060d269cb386a9613772c3bba74fd /net/wireless/ap.c | |
parent | b1fbd46976d047a6d6767872a9112afaa914fd82 (diff) |
cfg80211: introduce cfg80211_stop_ap
This functionality will be reused when interface
is going down. Avoids code duplication. Also adds
missing wdev locking.
Signed-off-by: Michal Kazior <michal.kazior@tieto.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Diffstat (limited to 'net/wireless/ap.c')
-rw-r--r-- | net/wireless/ap.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/net/wireless/ap.c b/net/wireless/ap.c new file mode 100644 index 000000000000..45199cca63d5 --- /dev/null +++ b/net/wireless/ap.c | |||
@@ -0,0 +1,44 @@ | |||
1 | #include <linux/ieee80211.h> | ||
2 | #include <linux/export.h> | ||
3 | #include <net/cfg80211.h> | ||
4 | #include "nl80211.h" | ||
5 | #include "core.h" | ||
6 | |||
7 | |||
8 | static int __cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | ||
9 | struct net_device *dev) | ||
10 | { | ||
11 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
12 | int err; | ||
13 | |||
14 | ASSERT_WDEV_LOCK(wdev); | ||
15 | |||
16 | if (!rdev->ops->stop_ap) | ||
17 | return -EOPNOTSUPP; | ||
18 | |||
19 | if (dev->ieee80211_ptr->iftype != NL80211_IFTYPE_AP && | ||
20 | dev->ieee80211_ptr->iftype != NL80211_IFTYPE_P2P_GO) | ||
21 | return -EOPNOTSUPP; | ||
22 | |||
23 | if (!wdev->beacon_interval) | ||
24 | return -ENOENT; | ||
25 | |||
26 | err = rdev->ops->stop_ap(&rdev->wiphy, dev); | ||
27 | if (!err) | ||
28 | wdev->beacon_interval = 0; | ||
29 | |||
30 | return err; | ||
31 | } | ||
32 | |||
33 | int cfg80211_stop_ap(struct cfg80211_registered_device *rdev, | ||
34 | struct net_device *dev) | ||
35 | { | ||
36 | struct wireless_dev *wdev = dev->ieee80211_ptr; | ||
37 | int err; | ||
38 | |||
39 | wdev_lock(wdev); | ||
40 | err = __cfg80211_stop_ap(rdev, dev); | ||
41 | wdev_unlock(wdev); | ||
42 | |||
43 | return err; | ||
44 | } | ||