319-v4.12-0045-brcmfmac-only-add-channels-and-ssids-once-in-scan-re.patch 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. From 6ea51fc708aedcf411f355de65a704ecda501bc4 Mon Sep 17 00:00:00 2001
  2. From: Arend Van Spriel <arend.vanspriel@broadcom.com>
  3. Date: Thu, 6 Apr 2017 13:14:42 +0100
  4. Subject: [PATCH] brcmfmac: only add channels and ssids once in scan request
  5. When receiving pno results there may be duplicate channels and/or
  6. ssids. Assure each is added only once when preparing the internal
  7. escan request.
  8. Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
  9. Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
  10. Reviewed-by: Franky Lin <franky.lin@broadcom.com>
  11. Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  12. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  13. ---
  14. .../broadcom/brcm80211/brcmfmac/cfg80211.c | 20 +++++++++++++++----
  15. 1 file changed, 16 insertions(+), 4 deletions(-)
  16. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  17. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  18. @@ -3216,7 +3216,7 @@ static int brcmf_internal_escan_add_info
  19. {
  20. struct ieee80211_channel *chan;
  21. enum nl80211_band band;
  22. - int freq;
  23. + int freq, i;
  24. if (channel <= CH_MAX_2G_CHANNEL)
  25. band = NL80211_BAND_2GHZ;
  26. @@ -3231,10 +3231,22 @@ static int brcmf_internal_escan_add_info
  27. if (!chan)
  28. return -EINVAL;
  29. - req->channels[req->n_channels++] = chan;
  30. - memcpy(req->ssids[req->n_ssids].ssid, ssid, ssid_len);
  31. - req->ssids[req->n_ssids++].ssid_len = ssid_len;
  32. -
  33. + for (i = 0; i < req->n_channels; i++) {
  34. + if (req->channels[i] == chan)
  35. + break;
  36. + }
  37. + if (i == req->n_channels)
  38. + req->channels[req->n_channels++] = chan;
  39. +
  40. + for (i = 0; i < req->n_ssids; i++) {
  41. + if (req->ssids[i].ssid_len == ssid_len &&
  42. + !memcmp(req->ssids[i].ssid, ssid, ssid_len))
  43. + break;
  44. + }
  45. + if (i == req->n_ssids) {
  46. + memcpy(req->ssids[req->n_ssids].ssid, ssid, ssid_len);
  47. + req->ssids[req->n_ssids++].ssid_len = ssid_len;
  48. + }
  49. return 0;
  50. }