diff options
Diffstat (limited to 'net/mac80211/cfg.c')
-rw-r--r-- | net/mac80211/cfg.c | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c index a352e4d22dd9..986e9a139d42 100644 --- a/net/mac80211/cfg.c +++ b/net/mac80211/cfg.c | |||
@@ -1996,33 +1996,46 @@ static int ieee80211_set_tx_power(struct wiphy *wiphy, | |||
1996 | enum nl80211_tx_power_setting type, int mbm) | 1996 | enum nl80211_tx_power_setting type, int mbm) |
1997 | { | 1997 | { |
1998 | struct ieee80211_local *local = wiphy_priv(wiphy); | 1998 | struct ieee80211_local *local = wiphy_priv(wiphy); |
1999 | struct ieee80211_channel *chan = local->_oper_channel; | 1999 | struct ieee80211_sub_if_data *sdata; |
2000 | u32 changes = 0; | ||
2001 | 2000 | ||
2002 | /* FIXME */ | 2001 | if (wdev) { |
2003 | if (local->use_chanctx) | 2002 | sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); |
2004 | return -EOPNOTSUPP; | 2003 | |
2004 | switch (type) { | ||
2005 | case NL80211_TX_POWER_AUTOMATIC: | ||
2006 | sdata->user_power_level = IEEE80211_UNSET_POWER_LEVEL; | ||
2007 | break; | ||
2008 | case NL80211_TX_POWER_LIMITED: | ||
2009 | case NL80211_TX_POWER_FIXED: | ||
2010 | if (mbm < 0 || (mbm % 100)) | ||
2011 | return -EOPNOTSUPP; | ||
2012 | sdata->user_power_level = MBM_TO_DBM(mbm); | ||
2013 | break; | ||
2014 | } | ||
2015 | |||
2016 | ieee80211_recalc_txpower(sdata); | ||
2017 | |||
2018 | return 0; | ||
2019 | } | ||
2005 | 2020 | ||
2006 | switch (type) { | 2021 | switch (type) { |
2007 | case NL80211_TX_POWER_AUTOMATIC: | 2022 | case NL80211_TX_POWER_AUTOMATIC: |
2008 | local->user_power_level = -1; | 2023 | local->user_power_level = IEEE80211_UNSET_POWER_LEVEL; |
2009 | break; | 2024 | break; |
2010 | case NL80211_TX_POWER_LIMITED: | 2025 | case NL80211_TX_POWER_LIMITED: |
2011 | if (mbm < 0 || (mbm % 100)) | ||
2012 | return -EOPNOTSUPP; | ||
2013 | local->user_power_level = MBM_TO_DBM(mbm); | ||
2014 | break; | ||
2015 | case NL80211_TX_POWER_FIXED: | 2026 | case NL80211_TX_POWER_FIXED: |
2016 | if (mbm < 0 || (mbm % 100)) | 2027 | if (mbm < 0 || (mbm % 100)) |
2017 | return -EOPNOTSUPP; | 2028 | return -EOPNOTSUPP; |
2018 | /* TODO: move to cfg80211 when it knows the channel */ | ||
2019 | if (MBM_TO_DBM(mbm) > chan->max_power) | ||
2020 | return -EINVAL; | ||
2021 | local->user_power_level = MBM_TO_DBM(mbm); | 2029 | local->user_power_level = MBM_TO_DBM(mbm); |
2022 | break; | 2030 | break; |
2023 | } | 2031 | } |
2024 | 2032 | ||
2025 | ieee80211_hw_config(local, changes); | 2033 | mutex_lock(&local->iflist_mtx); |
2034 | list_for_each_entry(sdata, &local->interfaces, list) | ||
2035 | sdata->user_power_level = local->user_power_level; | ||
2036 | list_for_each_entry(sdata, &local->interfaces, list) | ||
2037 | ieee80211_recalc_txpower(sdata); | ||
2038 | mutex_unlock(&local->iflist_mtx); | ||
2026 | 2039 | ||
2027 | return 0; | 2040 | return 0; |
2028 | } | 2041 | } |
@@ -2032,8 +2045,12 @@ static int ieee80211_get_tx_power(struct wiphy *wiphy, | |||
2032 | int *dbm) | 2045 | int *dbm) |
2033 | { | 2046 | { |
2034 | struct ieee80211_local *local = wiphy_priv(wiphy); | 2047 | struct ieee80211_local *local = wiphy_priv(wiphy); |
2048 | struct ieee80211_sub_if_data *sdata = IEEE80211_WDEV_TO_SUB_IF(wdev); | ||
2035 | 2049 | ||
2036 | *dbm = local->hw.conf.power_level; | 2050 | if (!local->use_chanctx) |
2051 | *dbm = local->hw.conf.power_level; | ||
2052 | else | ||
2053 | *dbm = sdata->vif.bss_conf.txpower; | ||
2037 | 2054 | ||
2038 | return 0; | 2055 | return 0; |
2039 | } | 2056 | } |