diff options
author | Mattias Nissler <mattias.nissler@gmx.de> | 2007-10-24 17:30:36 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 17:54:19 -0500 |
commit | 6a4329554c527e86c2745bc001c29bb8d1b8efaf (patch) | |
tree | e85887daee02c3df9af312c83b085a39c414b218 | |
parent | c7b6ea24b43afb5749cb704e143df19d70e23dea (diff) |
mac80211: Accept auto txpower setting
This changes the SIWTXPOWER ioctl to also accept a txpower setting of
"automatic". Since mac80211 currently cannot tell drivers to automatically
adjust tx power, we select the tx power level of the current channel. While
this is kind of a hack, it certainly saves some iwconfig users from headaches.
Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | net/mac80211/ieee80211_ioctl.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/net/mac80211/ieee80211_ioctl.c b/net/mac80211/ieee80211_ioctl.c index 308bbe4a1333..da3350d44da1 100644 --- a/net/mac80211/ieee80211_ioctl.c +++ b/net/mac80211/ieee80211_ioctl.c | |||
@@ -634,22 +634,35 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev, | |||
634 | { | 634 | { |
635 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); | 635 | struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr); |
636 | bool need_reconfig = 0; | 636 | bool need_reconfig = 0; |
637 | u8 new_power_level; | ||
637 | 638 | ||
638 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) | 639 | if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM) |
639 | return -EINVAL; | 640 | return -EINVAL; |
640 | if (data->txpower.flags & IW_TXPOW_RANGE) | 641 | if (data->txpower.flags & IW_TXPOW_RANGE) |
641 | return -EINVAL; | 642 | return -EINVAL; |
642 | if (!data->txpower.fixed) | ||
643 | return -EINVAL; | ||
644 | 643 | ||
645 | if (local->hw.conf.power_level != data->txpower.value) { | 644 | if (data->txpower.fixed) { |
646 | local->hw.conf.power_level = data->txpower.value; | 645 | new_power_level = data->txpower.value; |
646 | } else { | ||
647 | /* Automatic power level. Get the px power from the current | ||
648 | * channel. */ | ||
649 | struct ieee80211_channel* chan = local->oper_channel; | ||
650 | if (!chan) | ||
651 | return -EINVAL; | ||
652 | |||
653 | new_power_level = chan->power_level; | ||
654 | } | ||
655 | |||
656 | if (local->hw.conf.power_level != new_power_level) { | ||
657 | local->hw.conf.power_level = new_power_level; | ||
647 | need_reconfig = 1; | 658 | need_reconfig = 1; |
648 | } | 659 | } |
660 | |||
649 | if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) { | 661 | if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) { |
650 | local->hw.conf.radio_enabled = !(data->txpower.disabled); | 662 | local->hw.conf.radio_enabled = !(data->txpower.disabled); |
651 | need_reconfig = 1; | 663 | need_reconfig = 1; |
652 | } | 664 | } |
665 | |||
653 | if (need_reconfig) { | 666 | if (need_reconfig) { |
654 | ieee80211_hw_config(local); | 667 | ieee80211_hw_config(local); |
655 | /* The return value of hw_config is not of big interest here, | 668 | /* The return value of hw_config is not of big interest here, |