mac80211: Fix the maximum transmit power with power constraint
authorHong Wu <Hong.Wu@dspg.com>
Wed, 11 Jan 2012 18:34:30 +0000 (20:34 +0200)
committerJohn W. Linville <linville@tuxdriver.com>
Tue, 24 Jan 2012 19:21:11 +0000 (14:21 -0500)
The local maximum transmit power for a channel is defined as the maximum
regulatory transmission power minus the local power constraint specified
for the channel in the Power Constraint element. (7.3.2.15 IEEE80211 2007)

Signed-off-by: Hong Wu <hong.wu@dspg.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/mac80211/main.c
net/mac80211/mlme.c

index 0a0d94ad9b08374fe90e0f653da4d4b352e8f6c9..6192caadfab99689f5eb3886bf2032adcf14a2f6 100644 (file)
@@ -155,7 +155,8 @@ int ieee80211_hw_config(struct ieee80211_local *local, u32 changed)
                power = chan->max_power;
        else
                power = local->power_constr_level ?
-                       (chan->max_power - local->power_constr_level) :
+                       min(chan->max_power,
+                               (chan->max_reg_power  - local->power_constr_level)) :
                        chan->max_power;
 
        if (local->user_power_level >= 0)
index ecb4c84c1bb389decfedfb182bea2b534dcd258d..95d3964fc080a15cb84c039e1194da47672fb60c 100644 (file)
@@ -547,7 +547,7 @@ static void ieee80211_handle_pwr_constr(struct ieee80211_sub_if_data *sdata,
        if (pwr_constr_elem_len != 1)
                return;
 
-       if ((*pwr_constr_elem <= conf->channel->max_power) &&
+       if ((*pwr_constr_elem <= conf->channel->max_reg_power) &&
            (*pwr_constr_elem != sdata->local->power_constr_level)) {
                sdata->local->power_constr_level = *pwr_constr_elem;
                ieee80211_hw_config(sdata->local, 0);