This quiesces devices when appropriate to ensure that regulatory domain updates take effect and avoid having devices initiate radiation when they should not. Signed-off-by: Luis R. Rodriguez <mcgrof@xxxxxxxxxxxxxxxx> --- net/wireless/reg.c | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/net/wireless/reg.c b/net/wireless/reg.c index e5935c2..3036093 100644 --- a/net/wireless/reg.c +++ b/net/wireless/reg.c @@ -1287,12 +1287,65 @@ static void reg_call_notifier(struct wiphy *wiphy, wiphy->reg_notifier(wiphy, request); } +static void wiphy_regulatory_quiesce_all(struct wiphy *wiphy) +{ + struct cfg80211_registered_device *rdev; + + rdev = wiphy_to_dev(wiphy); + if (!rdev) + return; + + cfg80211_leave_all(rdev); +} + +static void wiphy_regulatory_quiesce_skip_wdev(struct wiphy *wiphy, + struct regulatory_request *lr) +{ + struct cfg80211_registered_device *rdev; + struct wiphy *last_wiphy = NULL; + struct wireless_dev *wdev; + + rdev = wiphy_to_dev(wiphy); + if (!rdev) + return; + + last_wiphy = wiphy_idx_to_wiphy(lr->wiphy_idx); + if (last_wiphy != wiphy) { + cfg80211_leave_all(rdev); + return; + } + + list_for_each_entry(wdev, &rdev->wdev_list, list) + if (lr->wdev != wdev) + cfg80211_leave(rdev, wdev); +} + +static void wiphy_regulatory_quiesce(struct wiphy *wiphy, + struct regulatory_request *lr) +{ + switch (lr->initiator) { + case NL80211_REGDOM_SET_BY_CORE: + return; + case NL80211_REGDOM_SET_BY_USER: + wiphy_regulatory_quiesce_all(wiphy); + return; + case NL80211_REGDOM_SET_BY_DRIVER: + wiphy_regulatory_quiesce_all(wiphy); + return; + case NL80211_REGDOM_SET_BY_COUNTRY_IE: + wiphy_regulatory_quiesce_skip_wdev(wiphy, lr); + return; + } +} + static void wiphy_update_regulatory(struct wiphy *wiphy, enum nl80211_reg_initiator initiator) { enum ieee80211_band band; struct regulatory_request *lr = get_last_request(); + wiphy_regulatory_quiesce(wiphy, lr); + if (ignore_reg_update(wiphy, initiator)) { /* * Regulatory updates set by CORE are ignored for custom -- 1.8.4.rc3 -- To unsubscribe from this list: send the line "unsubscribe linux-wireless" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html