提交 49540d1b 编写于 作者: E Eliad Peller 提交者: Luciano Coelho

wlcore: clarify and fix regulatory domain bit translation

Channels 52-64 were mapped incorrectly.

Refactor and document wlcore_get_reg_conf_ch_idx() in
order to make it clear what's going on there.

While on it, fix the return value check to consider
0 as a valid return value as well (indicates channel 1).
Reported-by: NYaniv Machani <yanivma@ti.com>
Signed-off-by: NEliad Peller <eliad@wizery.com>
Signed-off-by: NIdo Reis <idor@ti.com>
Signed-off-by: NVictor Goldenshtein <victorg@ti.com>
Signed-off-by: NLuciano Coelho <luciano.coelho@intel.com>
上级 7ca38a98
......@@ -1607,33 +1607,43 @@ int wl12xx_cmd_remove_peer(struct wl1271 *wl, u8 hlid)
static int wlcore_get_reg_conf_ch_idx(enum ieee80211_band band, u16 ch)
{
int idx = -1;
/*
* map the given band/channel to the respective predefined
* bit expected by the fw
*/
switch (band) {
case IEEE80211_BAND_5GHZ:
if (ch >= 8 && ch <= 16)
idx = ((ch-8)/4 + 18);
else if (ch >= 34 && ch <= 64)
idx = ((ch-34)/2 + 3 + 18);
else if (ch >= 100 && ch <= 140)
idx = ((ch-100)/4 + 15 + 18);
else if (ch >= 149 && ch <= 165)
idx = ((ch-149)/4 + 26 + 18);
else
idx = -1;
break;
case IEEE80211_BAND_2GHZ:
/* channels 1..14 are mapped to 0..13 */
if (ch >= 1 && ch <= 14)
idx = ch - 1;
else
idx = -1;
return ch - 1;
break;
case IEEE80211_BAND_5GHZ:
switch (ch) {
case 8 ... 16:
/* channels 8,12,16 are mapped to 18,19,20 */
return 18 + (ch-8)/4;
case 34 ... 48:
/* channels 34,36..48 are mapped to 21..28 */
return 21 + (ch-34)/2;
case 52 ... 64:
/* channels 52,56..64 are mapped to 29..32 */
return 29 + (ch-52)/4;
case 100 ... 140:
/* channels 100,104..140 are mapped to 33..43 */
return 33 + (ch-100)/4;
case 149 ... 165:
/* channels 149,153..165 are mapped to 44..48 */
return 44 + (ch-149)/4;
default:
break;
}
break;
default:
wl1271_error("get reg conf ch idx - unknown band: %d",
(int)band);
break;
}
return idx;
wl1271_error("%s: unknown band/channel: %d/%d", __func__, band, ch);
return -1;
}
void wlcore_set_pending_regdomain_ch(struct wl1271 *wl, u16 channel,
......@@ -1646,7 +1656,7 @@ void wlcore_set_pending_regdomain_ch(struct wl1271 *wl, u16 channel,
ch_bit_idx = wlcore_get_reg_conf_ch_idx(band, channel);
if (ch_bit_idx > 0 && ch_bit_idx <= WL1271_MAX_CHANNELS)
if (ch_bit_idx >= 0 && ch_bit_idx <= WL1271_MAX_CHANNELS)
set_bit(ch_bit_idx, (long *)wl->reg_ch_conf_pending);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册