Skip to content

Commit

Permalink
mac80211: make use of regulatory tx power settings on change of tx power
Browse files Browse the repository at this point in the history
We do not know what max power to allow until a device is targeting
a channel, therefore only allow changing tx power if a channel is defined.
Also make use of the channel's max power setting as defined by
regulatory rules before allowing the user to use the requested power
setting. If the user asked us to figure it out we use the max allowed
by regulatory.

Signed-off-by: Luis R. Rodriguez <lrodriguez@atheros.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
  • Loading branch information
Luis R. Rodriguez authored and John W. Linville committed Oct 31, 2008
1 parent e2ef12d commit d9d2925
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions net/mac80211/wext.c
Original file line number Diff line number Diff line change
Expand Up @@ -656,27 +656,21 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev,
union iwreq_data *data, char *extra)
{
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
struct ieee80211_channel* chan = local->hw.conf.channel;
u32 reconf_flags = 0;
int new_power_level;

if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
return -EINVAL;
if (data->txpower.flags & IW_TXPOW_RANGE)
return -EINVAL;
if (!chan)
return -EINVAL;

if (data->txpower.fixed) {
new_power_level = data->txpower.value;
} else {
/*
* Automatic power level. Use maximum power for the current
* channel. Should be part of rate control.
*/
struct ieee80211_channel* chan = local->hw.conf.channel;
if (!chan)
return -EINVAL;

if (data->txpower.fixed)
new_power_level = min(data->txpower.value, chan->max_power);
else /* Automatic power level setting */
new_power_level = chan->max_power;
}

if (local->hw.conf.power_level != new_power_level) {
local->hw.conf.power_level = new_power_level;
Expand Down

0 comments on commit d9d2925

Please sign in to comment.