xref: /openbmc/linux/net/wireless/ap.c (revision 95e9fd10)
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 		wdev->channel = NULL;
30 	}
31 
32 	return err;
33 }
34 
35 int cfg80211_stop_ap(struct cfg80211_registered_device *rdev,
36 		     struct net_device *dev)
37 {
38 	struct wireless_dev *wdev = dev->ieee80211_ptr;
39 	int err;
40 
41 	wdev_lock(wdev);
42 	err = __cfg80211_stop_ap(rdev, dev);
43 	wdev_unlock(wdev);
44 
45 	return err;
46 }
47