Commit 9c8e98a0 authored by Adrian Bunk's avatar Adrian Bunk Committed by Greg Kroah-Hartman

mwifiex: Fix NL80211_TX_POWER_LIMITED

[ Upstream commit 65a576e2 ]

NL80211_TX_POWER_LIMITED was treated as NL80211_TX_POWER_AUTOMATIC,
which is the opposite of what should happen and can cause nasty
regulatory problems.

if/else converted to a switch without default to make gcc warn
on unhandled enum values.
Signed-off-by: default avatarAdrian Bunk <bunk@kernel.org>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 0533daaa
...@@ -364,11 +364,20 @@ mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy, ...@@ -364,11 +364,20 @@ mwifiex_cfg80211_set_tx_power(struct wiphy *wiphy,
struct mwifiex_power_cfg power_cfg; struct mwifiex_power_cfg power_cfg;
int dbm = MBM_TO_DBM(mbm); int dbm = MBM_TO_DBM(mbm);
if (type == NL80211_TX_POWER_FIXED) { switch (type) {
case NL80211_TX_POWER_FIXED:
power_cfg.is_power_auto = 0; power_cfg.is_power_auto = 0;
power_cfg.is_power_fixed = 1;
power_cfg.power_level = dbm; power_cfg.power_level = dbm;
} else { break;
case NL80211_TX_POWER_LIMITED:
power_cfg.is_power_auto = 0;
power_cfg.is_power_fixed = 0;
power_cfg.power_level = dbm;
break;
case NL80211_TX_POWER_AUTOMATIC:
power_cfg.is_power_auto = 1; power_cfg.is_power_auto = 1;
break;
} }
priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY); priv = mwifiex_get_priv(adapter, MWIFIEX_BSS_ROLE_ANY);
......
...@@ -265,6 +265,7 @@ struct mwifiex_ds_encrypt_key { ...@@ -265,6 +265,7 @@ struct mwifiex_ds_encrypt_key {
struct mwifiex_power_cfg { struct mwifiex_power_cfg {
u32 is_power_auto; u32 is_power_auto;
u32 is_power_fixed;
u32 power_level; u32 power_level;
}; };
......
...@@ -728,6 +728,9 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, ...@@ -728,6 +728,9 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf; txp_cfg = (struct host_cmd_ds_txpwr_cfg *) buf;
txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET); txp_cfg->action = cpu_to_le16(HostCmd_ACT_GEN_SET);
if (!power_cfg->is_power_auto) { if (!power_cfg->is_power_auto) {
u16 dbm_min = power_cfg->is_power_fixed ?
dbm : priv->min_tx_power_level;
txp_cfg->mode = cpu_to_le32(1); txp_cfg->mode = cpu_to_le32(1);
pg_tlv = (struct mwifiex_types_power_group *) pg_tlv = (struct mwifiex_types_power_group *)
(buf + sizeof(struct host_cmd_ds_txpwr_cfg)); (buf + sizeof(struct host_cmd_ds_txpwr_cfg));
...@@ -742,7 +745,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, ...@@ -742,7 +745,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
pg->last_rate_code = 0x03; pg->last_rate_code = 0x03;
pg->modulation_class = MOD_CLASS_HR_DSSS; pg->modulation_class = MOD_CLASS_HR_DSSS;
pg->power_step = 0; pg->power_step = 0;
pg->power_min = (s8) dbm; pg->power_min = (s8) dbm_min;
pg->power_max = (s8) dbm; pg->power_max = (s8) dbm;
pg++; pg++;
/* Power group for modulation class OFDM */ /* Power group for modulation class OFDM */
...@@ -750,7 +753,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, ...@@ -750,7 +753,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
pg->last_rate_code = 0x07; pg->last_rate_code = 0x07;
pg->modulation_class = MOD_CLASS_OFDM; pg->modulation_class = MOD_CLASS_OFDM;
pg->power_step = 0; pg->power_step = 0;
pg->power_min = (s8) dbm; pg->power_min = (s8) dbm_min;
pg->power_max = (s8) dbm; pg->power_max = (s8) dbm;
pg++; pg++;
/* Power group for modulation class HTBW20 */ /* Power group for modulation class HTBW20 */
...@@ -758,7 +761,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, ...@@ -758,7 +761,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
pg->last_rate_code = 0x20; pg->last_rate_code = 0x20;
pg->modulation_class = MOD_CLASS_HT; pg->modulation_class = MOD_CLASS_HT;
pg->power_step = 0; pg->power_step = 0;
pg->power_min = (s8) dbm; pg->power_min = (s8) dbm_min;
pg->power_max = (s8) dbm; pg->power_max = (s8) dbm;
pg->ht_bandwidth = HT_BW_20; pg->ht_bandwidth = HT_BW_20;
pg++; pg++;
...@@ -767,7 +770,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv, ...@@ -767,7 +770,7 @@ int mwifiex_set_tx_power(struct mwifiex_private *priv,
pg->last_rate_code = 0x20; pg->last_rate_code = 0x20;
pg->modulation_class = MOD_CLASS_HT; pg->modulation_class = MOD_CLASS_HT;
pg->power_step = 0; pg->power_step = 0;
pg->power_min = (s8) dbm; pg->power_min = (s8) dbm_min;
pg->power_max = (s8) dbm; pg->power_max = (s8) dbm;
pg->ht_bandwidth = HT_BW_40; pg->ht_bandwidth = HT_BW_40;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment