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>
This commit is contained in:
parent
c7b6ea24b4
commit
6a4329554c
|
@ -634,22 +634,35 @@ static int ieee80211_ioctl_siwtxpower(struct net_device *dev,
|
||||||
{
|
{
|
||||||
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
struct ieee80211_local *local = wdev_priv(dev->ieee80211_ptr);
|
||||||
bool need_reconfig = 0;
|
bool need_reconfig = 0;
|
||||||
|
u8 new_power_level;
|
||||||
|
|
||||||
if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
if ((data->txpower.flags & IW_TXPOW_TYPE) != IW_TXPOW_DBM)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (data->txpower.flags & IW_TXPOW_RANGE)
|
if (data->txpower.flags & IW_TXPOW_RANGE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
if (!data->txpower.fixed)
|
|
||||||
return -EINVAL;
|
|
||||||
|
|
||||||
if (local->hw.conf.power_level != data->txpower.value) {
|
if (data->txpower.fixed) {
|
||||||
local->hw.conf.power_level = data->txpower.value;
|
new_power_level = data->txpower.value;
|
||||||
|
} else {
|
||||||
|
/* Automatic power level. Get the px power from the current
|
||||||
|
* channel. */
|
||||||
|
struct ieee80211_channel* chan = local->oper_channel;
|
||||||
|
if (!chan)
|
||||||
|
return -EINVAL;
|
||||||
|
|
||||||
|
new_power_level = chan->power_level;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (local->hw.conf.power_level != new_power_level) {
|
||||||
|
local->hw.conf.power_level = new_power_level;
|
||||||
need_reconfig = 1;
|
need_reconfig = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) {
|
if (local->hw.conf.radio_enabled != !(data->txpower.disabled)) {
|
||||||
local->hw.conf.radio_enabled = !(data->txpower.disabled);
|
local->hw.conf.radio_enabled = !(data->txpower.disabled);
|
||||||
need_reconfig = 1;
|
need_reconfig = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (need_reconfig) {
|
if (need_reconfig) {
|
||||||
ieee80211_hw_config(local);
|
ieee80211_hw_config(local);
|
||||||
/* The return value of hw_config is not of big interest here,
|
/* The return value of hw_config is not of big interest here,
|
||||||
|
|
Loading…
Reference in New Issue