cfg80211: Restore orig channel values upon disconnect
authorRajkumar Manoharan <rmanohar@qca.qualcomm.com>
Wed, 7 Dec 2011 16:20:08 +0000 (21:50 +0530)
committerJohn W. Linville <linville@tuxdriver.com>
Fri, 16 Dec 2011 14:30:43 +0000 (09:30 -0500)
When we restore regulatory settings the world regulatory domain
is properly reset on cfg80211 (or user prefered regulatory domain)
but we were never setting back channel values for drivers that use
WIPHY_FLAG_CUSTOM_REGULATORY. Set these values up again by using
the orig_ channel parameters.

This fixes restoring custom regulatory settings upon disconnect
events.

Cc: compat@orbit-lab.org
Cc: Paul Stewart <pstew@google.com>
Cc: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Cc: Senthilkumar Balasubramanian <senthilb@qca.qualcomm.com>
Signed-off-by: Rajkumar Manoharan <rmanohar@qca.qualcomm.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/wireless/reg.c

index 481caafc6ba5bda9e712205fe7aa4cce7a104c6a..c45c8b772dddec9c731a9d60c47eaa6318cc7f4e 100644 (file)
@@ -1792,6 +1792,26 @@ static void restore_alpha2(char *alpha2, bool reset_user)
                REG_DBG_PRINT("Restoring regulatory settings\n");
 }
 
+static void restore_custom_reg_settings(struct wiphy *wiphy)
+{
+       struct ieee80211_supported_band *sband;
+       enum ieee80211_band band;
+       struct ieee80211_channel *chan;
+       int i;
+
+       for (band = 0; band < IEEE80211_NUM_BANDS; band++) {
+               sband = wiphy->bands[band];
+               if (!sband)
+                       continue;
+               for (i = 0; i < sband->n_channels; i++) {
+                       chan = &sband->channels[i];
+                       chan->flags = chan->orig_flags;
+                       chan->max_antenna_gain = chan->orig_mag;
+                       chan->max_power = chan->orig_mpwr;
+               }
+       }
+}
+
 /*
  * Restoring regulatory settings involves ingoring any
  * possibly stale country IE information and user regulatory
@@ -1813,6 +1833,7 @@ static void restore_regulatory_settings(bool reset_user)
        struct reg_beacon *reg_beacon, *btmp;
        struct regulatory_request *reg_request, *tmp;
        LIST_HEAD(tmp_reg_req_list);
+       struct cfg80211_registered_device *rdev;
 
        mutex_lock(&cfg80211_mutex);
        mutex_lock(&reg_mutex);
@@ -1861,6 +1882,11 @@ static void restore_regulatory_settings(bool reset_user)
        /* First restore to the basic regulatory settings */
        cfg80211_regdomain = cfg80211_world_regdom;
 
+       list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
+               if (rdev->wiphy.flags & WIPHY_FLAG_CUSTOM_REGULATORY)
+                       restore_custom_reg_settings(&rdev->wiphy);
+       }
+
        mutex_unlock(&reg_mutex);
        mutex_unlock(&cfg80211_mutex);