diff options
Diffstat (limited to 'net/wireless/reg.c')
-rw-r--r-- | net/wireless/reg.c | 56 |
1 files changed, 34 insertions, 22 deletions
diff --git a/net/wireless/reg.c b/net/wireless/reg.c index 7b8309840d4e..d39d1cbc86b1 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c | |||
@@ -1530,45 +1530,40 @@ static void reg_call_notifier(struct wiphy *wiphy, | |||
1530 | 1530 | ||
1531 | static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev) | 1531 | static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev) |
1532 | { | 1532 | { |
1533 | struct ieee80211_channel *ch; | ||
1534 | struct cfg80211_chan_def chandef; | 1533 | struct cfg80211_chan_def chandef; |
1535 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); | 1534 | struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy); |
1536 | bool ret = true; | 1535 | enum nl80211_iftype iftype; |
1537 | 1536 | ||
1538 | wdev_lock(wdev); | 1537 | wdev_lock(wdev); |
1538 | iftype = wdev->iftype; | ||
1539 | 1539 | ||
1540 | /* make sure the interface is active */ | ||
1540 | if (!wdev->netdev || !netif_running(wdev->netdev)) | 1541 | if (!wdev->netdev || !netif_running(wdev->netdev)) |
1541 | goto out; | 1542 | goto wdev_inactive_unlock; |
1542 | 1543 | ||
1543 | switch (wdev->iftype) { | 1544 | switch (iftype) { |
1544 | case NL80211_IFTYPE_AP: | 1545 | case NL80211_IFTYPE_AP: |
1545 | case NL80211_IFTYPE_P2P_GO: | 1546 | case NL80211_IFTYPE_P2P_GO: |
1546 | if (!wdev->beacon_interval) | 1547 | if (!wdev->beacon_interval) |
1547 | goto out; | 1548 | goto wdev_inactive_unlock; |
1548 | 1549 | chandef = wdev->chandef; | |
1549 | ret = cfg80211_reg_can_beacon(wiphy, | ||
1550 | &wdev->chandef, wdev->iftype); | ||
1551 | break; | 1550 | break; |
1552 | case NL80211_IFTYPE_ADHOC: | 1551 | case NL80211_IFTYPE_ADHOC: |
1553 | if (!wdev->ssid_len) | 1552 | if (!wdev->ssid_len) |
1554 | goto out; | 1553 | goto wdev_inactive_unlock; |
1555 | 1554 | chandef = wdev->chandef; | |
1556 | ret = cfg80211_reg_can_beacon(wiphy, | ||
1557 | &wdev->chandef, wdev->iftype); | ||
1558 | break; | 1555 | break; |
1559 | case NL80211_IFTYPE_STATION: | 1556 | case NL80211_IFTYPE_STATION: |
1560 | case NL80211_IFTYPE_P2P_CLIENT: | 1557 | case NL80211_IFTYPE_P2P_CLIENT: |
1561 | if (!wdev->current_bss || | 1558 | if (!wdev->current_bss || |
1562 | !wdev->current_bss->pub.channel) | 1559 | !wdev->current_bss->pub.channel) |
1563 | goto out; | 1560 | goto wdev_inactive_unlock; |
1564 | 1561 | ||
1565 | ch = wdev->current_bss->pub.channel; | 1562 | if (!rdev->ops->get_channel || |
1566 | if (rdev->ops->get_channel && | 1563 | rdev_get_channel(rdev, wdev, &chandef)) |
1567 | !rdev_get_channel(rdev, wdev, &chandef)) | 1564 | cfg80211_chandef_create(&chandef, |
1568 | ret = cfg80211_chandef_usable(wiphy, &chandef, | 1565 | wdev->current_bss->pub.channel, |
1569 | IEEE80211_CHAN_DISABLED); | 1566 | NL80211_CHAN_NO_HT); |
1570 | else | ||
1571 | ret = !(ch->flags & IEEE80211_CHAN_DISABLED); | ||
1572 | break; | 1567 | break; |
1573 | case NL80211_IFTYPE_MONITOR: | 1568 | case NL80211_IFTYPE_MONITOR: |
1574 | case NL80211_IFTYPE_AP_VLAN: | 1569 | case NL80211_IFTYPE_AP_VLAN: |
@@ -1581,9 +1576,26 @@ static bool reg_wdev_chan_valid(struct wiphy *wiphy, struct wireless_dev *wdev) | |||
1581 | break; | 1576 | break; |
1582 | } | 1577 | } |
1583 | 1578 | ||
1584 | out: | ||
1585 | wdev_unlock(wdev); | 1579 | wdev_unlock(wdev); |
1586 | return ret; | 1580 | |
1581 | switch (iftype) { | ||
1582 | case NL80211_IFTYPE_AP: | ||
1583 | case NL80211_IFTYPE_P2P_GO: | ||
1584 | case NL80211_IFTYPE_ADHOC: | ||
1585 | return cfg80211_reg_can_beacon(wiphy, &chandef, iftype); | ||
1586 | case NL80211_IFTYPE_STATION: | ||
1587 | case NL80211_IFTYPE_P2P_CLIENT: | ||
1588 | return cfg80211_chandef_usable(wiphy, &chandef, | ||
1589 | IEEE80211_CHAN_DISABLED); | ||
1590 | default: | ||
1591 | break; | ||
1592 | } | ||
1593 | |||
1594 | return true; | ||
1595 | |||
1596 | wdev_inactive_unlock: | ||
1597 | wdev_unlock(wdev); | ||
1598 | return true; | ||
1587 | } | 1599 | } |
1588 | 1600 | ||
1589 | static void reg_leave_invalid_chans(struct wiphy *wiphy) | 1601 | static void reg_leave_invalid_chans(struct wiphy *wiphy) |