351-0019-brcmfmac-slightly-simplify-building-interface-combin.patch 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  2. Date: Tue, 7 Jun 2016 21:10:18 +0200
  3. Subject: [PATCH] brcmfmac: slightly simplify building interface combinations
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. This change reorders some operations in brcmf_setup_ifmodes in hope to
  8. make it simpler:
  9. 1) It allocates arrays right before filling them. This way it's easier
  10. to follow requested array length as it's immediately followed by
  11. code filling it. It's easier to check e.g. why we need 4 entries for
  12. P2P. Other than that it deduplicates some checks (e.g. for P2P).
  13. 2) It reorders code to first prepare limits and then define a new combo.
  14. Previously this was mixed (e.g. we were setting num of channels
  15. before preparing limits).
  16. 3) It modifies mbss code to use i variable just like other combos do.
  17. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  18. Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
  19. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  20. ---
  21. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  22. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
  23. @@ -6284,29 +6284,15 @@ static int brcmf_setup_ifmodes(struct wi
  24. if (!combo)
  25. goto err;
  26. - c0_limits = kcalloc(p2p ? 3 : 2, sizeof(*c0_limits), GFP_KERNEL);
  27. - if (!c0_limits)
  28. - goto err;
  29. -
  30. - if (p2p) {
  31. - p2p_limits = kcalloc(4, sizeof(*p2p_limits), GFP_KERNEL);
  32. - if (!p2p_limits)
  33. - goto err;
  34. - }
  35. -
  36. - if (mbss) {
  37. - mbss_limits = kcalloc(1, sizeof(*mbss_limits), GFP_KERNEL);
  38. - if (!mbss_limits)
  39. - goto err;
  40. - }
  41. -
  42. wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) |
  43. BIT(NL80211_IFTYPE_ADHOC) |
  44. BIT(NL80211_IFTYPE_AP);
  45. c = 0;
  46. i = 0;
  47. - combo[c].num_different_channels = 1;
  48. + c0_limits = kcalloc(p2p ? 3 : 2, sizeof(*c0_limits), GFP_KERNEL);
  49. + if (!c0_limits)
  50. + goto err;
  51. c0_limits[i].max = 1;
  52. c0_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
  53. if (p2p) {
  54. @@ -6324,6 +6310,7 @@ static int brcmf_setup_ifmodes(struct wi
  55. c0_limits[i].max = 1;
  56. c0_limits[i++].types = BIT(NL80211_IFTYPE_AP);
  57. }
  58. + combo[c].num_different_channels = 1;
  59. combo[c].max_interfaces = i;
  60. combo[c].n_limits = i;
  61. combo[c].limits = c0_limits;
  62. @@ -6331,7 +6318,9 @@ static int brcmf_setup_ifmodes(struct wi
  63. if (p2p) {
  64. c++;
  65. i = 0;
  66. - combo[c].num_different_channels = 1;
  67. + p2p_limits = kcalloc(4, sizeof(*p2p_limits), GFP_KERNEL);
  68. + if (!p2p_limits)
  69. + goto err;
  70. p2p_limits[i].max = 1;
  71. p2p_limits[i++].types = BIT(NL80211_IFTYPE_STATION);
  72. p2p_limits[i].max = 1;
  73. @@ -6340,6 +6329,7 @@ static int brcmf_setup_ifmodes(struct wi
  74. p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_CLIENT);
  75. p2p_limits[i].max = 1;
  76. p2p_limits[i++].types = BIT(NL80211_IFTYPE_P2P_DEVICE);
  77. + combo[c].num_different_channels = 1;
  78. combo[c].max_interfaces = i;
  79. combo[c].n_limits = i;
  80. combo[c].limits = p2p_limits;
  81. @@ -6347,14 +6337,19 @@ static int brcmf_setup_ifmodes(struct wi
  82. if (mbss) {
  83. c++;
  84. + i = 0;
  85. + mbss_limits = kcalloc(1, sizeof(*mbss_limits), GFP_KERNEL);
  86. + if (!mbss_limits)
  87. + goto err;
  88. + mbss_limits[i].max = 4;
  89. + mbss_limits[i++].types = BIT(NL80211_IFTYPE_AP);
  90. combo[c].beacon_int_infra_match = true;
  91. combo[c].num_different_channels = 1;
  92. - mbss_limits[0].max = 4;
  93. - mbss_limits[0].types = BIT(NL80211_IFTYPE_AP);
  94. combo[c].max_interfaces = 4;
  95. - combo[c].n_limits = 1;
  96. + combo[c].n_limits = i;
  97. combo[c].limits = mbss_limits;
  98. }
  99. +
  100. wiphy->n_iface_combinations = n_combos;
  101. wiphy->iface_combinations = combo;
  102. return 0;