Skip to content

Commit 36e8072

Browse files
rmileckiKalle Valo
authored andcommitted
brcmfmac: fix setting primary channel for 80 MHz width
First of all it changes the way we calculate primary channel offset. If we use e.g. 80 MHz channel with primary frequency 5180 MHz (which means center frequency is 5210 MHz) it makes sense to calculate primary offset as -30 MHz. Then it fixes values we compare primary_offset with. We were comparing offset in MHz against -2 or 2 which was resulting in picking a wrong primary channel. Signed-off-by: Rafał Miłecki <zajec5@gmail.com> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
1 parent b3c47af commit 36e8072

File tree

1 file changed

+10
-13
lines changed
  • drivers/net/wireless/broadcom/brcm80211/brcmfmac

1 file changed

+10
-13
lines changed

drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
247247
brcmf_dbg(TRACE, "chandef: control %d center %d width %d\n",
248248
ch->chan->center_freq, ch->center_freq1, ch->width);
249249
ch_inf.chnum = ieee80211_frequency_to_channel(ch->center_freq1);
250-
primary_offset = ch->center_freq1 - ch->chan->center_freq;
250+
primary_offset = ch->chan->center_freq - ch->center_freq1;
251251
switch (ch->width) {
252252
case NL80211_CHAN_WIDTH_20:
253253
case NL80211_CHAN_WIDTH_20_NOHT:
@@ -256,24 +256,21 @@ static u16 chandef_to_chanspec(struct brcmu_d11inf *d11inf,
256256
break;
257257
case NL80211_CHAN_WIDTH_40:
258258
ch_inf.bw = BRCMU_CHAN_BW_40;
259-
if (primary_offset < 0)
259+
if (primary_offset > 0)
260260
ch_inf.sb = BRCMU_CHAN_SB_U;
261261
else
262262
ch_inf.sb = BRCMU_CHAN_SB_L;
263263
break;
264264
case NL80211_CHAN_WIDTH_80:
265265
ch_inf.bw = BRCMU_CHAN_BW_80;
266-
if (primary_offset < 0) {
267-
if (primary_offset < -CH_10MHZ_APART)
268-
ch_inf.sb = BRCMU_CHAN_SB_UU;
269-
else
270-
ch_inf.sb = BRCMU_CHAN_SB_UL;
271-
} else {
272-
if (primary_offset > CH_10MHZ_APART)
273-
ch_inf.sb = BRCMU_CHAN_SB_LL;
274-
else
275-
ch_inf.sb = BRCMU_CHAN_SB_LU;
276-
}
266+
if (primary_offset == -30)
267+
ch_inf.sb = BRCMU_CHAN_SB_LL;
268+
else if (primary_offset == -10)
269+
ch_inf.sb = BRCMU_CHAN_SB_LU;
270+
else if (primary_offset == 10)
271+
ch_inf.sb = BRCMU_CHAN_SB_UL;
272+
else
273+
ch_inf.sb = BRCMU_CHAN_SB_UU;
277274
break;
278275
case NL80211_CHAN_WIDTH_80P80:
279276
case NL80211_CHAN_WIDTH_160:

0 commit comments

Comments
 (0)