Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 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); |
Michal Kazior | f4489eb | 2012-06-29 12:46:58 +0200 | [diff] [blame] | 27 | if (!err) { |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 28 | wdev->beacon_interval = 0; |
Michal Kazior | f4489eb | 2012-06-29 12:46:58 +0200 | [diff] [blame] | 29 | wdev->channel = NULL; |
| 30 | } |
Michal Kazior | 6077178 | 2012-06-29 12:46:56 +0200 | [diff] [blame] | 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 | } |