323-0000-brcmfmac-fix-setting-primary-channel-for-80-MHz-widt.patch 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  2. Date: Wed, 20 Jan 2016 16:46:04 +0100
  3. Subject: [PATCH] brcmfmac: fix setting primary channel for 80 MHz width
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. First of all it changes the way we calculate primary channel offset. If
  8. we use e.g. 80 MHz channel with primary frequency 5180 MHz (which means
  9. center frequency is 5210 MHz) it makes sense to calculate primary offset
  10. as -30 MHz.
  11. Then it fixes values we compare primary_offset with. We were comparing
  12. offset in MHz against -2 or 2 which was resulting in picking a wrong
  13. primary channel.
  14. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  15. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  16. ---
  17. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  18. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  19. @@ -247,7 +247,7 @@ static u16 chandef_to_chanspec(struct br
  20. brcmf_dbg(TRACE, "chandef: control %d center %d width %d\n",
  21. ch->chan->center_freq, ch->center_freq1, ch->width);
  22. ch_inf.chnum = ieee80211_frequency_to_channel(ch->center_freq1);
  23. - primary_offset = ch->center_freq1 - ch->chan->center_freq;
  24. + primary_offset = ch->chan->center_freq - ch->center_freq1;
  25. switch (ch->width) {
  26. case NL80211_CHAN_WIDTH_20:
  27. case NL80211_CHAN_WIDTH_20_NOHT:
  28. @@ -256,24 +256,21 @@ static u16 chandef_to_chanspec(struct br
  29. break;
  30. case NL80211_CHAN_WIDTH_40:
  31. ch_inf.bw = BRCMU_CHAN_BW_40;
  32. - if (primary_offset < 0)
  33. + if (primary_offset > 0)
  34. ch_inf.sb = BRCMU_CHAN_SB_U;
  35. else
  36. ch_inf.sb = BRCMU_CHAN_SB_L;
  37. break;
  38. case NL80211_CHAN_WIDTH_80:
  39. ch_inf.bw = BRCMU_CHAN_BW_80;
  40. - if (primary_offset < 0) {
  41. - if (primary_offset < -CH_10MHZ_APART)
  42. - ch_inf.sb = BRCMU_CHAN_SB_UU;
  43. - else
  44. - ch_inf.sb = BRCMU_CHAN_SB_UL;
  45. - } else {
  46. - if (primary_offset > CH_10MHZ_APART)
  47. - ch_inf.sb = BRCMU_CHAN_SB_LL;
  48. - else
  49. - ch_inf.sb = BRCMU_CHAN_SB_LU;
  50. - }
  51. + if (primary_offset == -30)
  52. + ch_inf.sb = BRCMU_CHAN_SB_LL;
  53. + else if (primary_offset == -10)
  54. + ch_inf.sb = BRCMU_CHAN_SB_LU;
  55. + else if (primary_offset == 10)
  56. + ch_inf.sb = BRCMU_CHAN_SB_UL;
  57. + else
  58. + ch_inf.sb = BRCMU_CHAN_SB_UU;
  59. break;
  60. case NL80211_CHAN_WIDTH_80P80:
  61. case NL80211_CHAN_WIDTH_160: