520-ath9k_multiple_cards_fix.patch 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. --- a/drivers/net/wireless/ath/ath9k/init.c
  2. +++ b/drivers/net/wireless/ath/ath9k/init.c
  3. @@ -57,7 +57,7 @@ MODULE_PARM_DESC(blink, "Enable LED blin
  4. * on 5 MHz steps, we support the channels which we know
  5. * we have calibration data for all cards though to make
  6. * this static */
  7. -static struct ieee80211_channel ath9k_2ghz_chantable[] = {
  8. +static const struct ieee80211_channel ath9k_2ghz_chantable[] = {
  9. CHAN2G(2412, 0), /* Channel 1 */
  10. CHAN2G(2417, 1), /* Channel 2 */
  11. CHAN2G(2422, 2), /* Channel 3 */
  12. @@ -78,7 +78,7 @@ static struct ieee80211_channel ath9k_2g
  13. * on 5 MHz steps, we support the channels which we know
  14. * we have calibration data for all cards though to make
  15. * this static */
  16. -static struct ieee80211_channel ath9k_5ghz_chantable[] = {
  17. +static const struct ieee80211_channel ath9k_5ghz_chantable[] = {
  18. /* _We_ call this UNII 1 */
  19. CHAN5G(5180, 14), /* Channel 36 */
  20. CHAN5G(5200, 15), /* Channel 40 */
  21. @@ -478,10 +478,17 @@ err:
  22. return -EIO;
  23. }
  24. -static void ath9k_init_channels_rates(struct ath_softc *sc)
  25. +static int ath9k_init_channels_rates(struct ath_softc *sc)
  26. {
  27. + void *channels;
  28. +
  29. if (test_bit(ATH9K_MODE_11G, sc->sc_ah->caps.wireless_modes)) {
  30. - sc->sbands[IEEE80211_BAND_2GHZ].channels = ath9k_2ghz_chantable;
  31. + channels = kmemdup(ath9k_2ghz_chantable,
  32. + sizeof(ath9k_2ghz_chantable), GFP_KERNEL);
  33. + if (!channels)
  34. + return -ENOMEM;
  35. +
  36. + sc->sbands[IEEE80211_BAND_2GHZ].channels = channels;
  37. sc->sbands[IEEE80211_BAND_2GHZ].band = IEEE80211_BAND_2GHZ;
  38. sc->sbands[IEEE80211_BAND_2GHZ].n_channels =
  39. ARRAY_SIZE(ath9k_2ghz_chantable);
  40. @@ -491,7 +498,15 @@ static void ath9k_init_channels_rates(st
  41. }
  42. if (test_bit(ATH9K_MODE_11A, sc->sc_ah->caps.wireless_modes)) {
  43. - sc->sbands[IEEE80211_BAND_5GHZ].channels = ath9k_5ghz_chantable;
  44. + channels = kmemdup(ath9k_5ghz_chantable,
  45. + sizeof(ath9k_5ghz_chantable), GFP_KERNEL);
  46. + if (!channels) {
  47. + if (sc->sbands[IEEE80211_BAND_2GHZ].channels)
  48. + kfree(sc->sbands[IEEE80211_BAND_2GHZ].channels);
  49. + return -ENOMEM;
  50. + }
  51. +
  52. + sc->sbands[IEEE80211_BAND_5GHZ].channels = channels;
  53. sc->sbands[IEEE80211_BAND_5GHZ].band = IEEE80211_BAND_5GHZ;
  54. sc->sbands[IEEE80211_BAND_5GHZ].n_channels =
  55. ARRAY_SIZE(ath9k_5ghz_chantable);
  56. @@ -500,6 +515,7 @@ static void ath9k_init_channels_rates(st
  57. sc->sbands[IEEE80211_BAND_5GHZ].n_bitrates =
  58. ARRAY_SIZE(ath9k_legacy_rates) - 4;
  59. }
  60. + return 0;
  61. }
  62. static void ath9k_init_misc(struct ath_softc *sc)
  63. @@ -602,8 +618,11 @@ static int ath9k_init_softc(u16 devid, s
  64. if (ret)
  65. goto err_btcoex;
  66. + ret = ath9k_init_channels_rates(sc);
  67. + if (ret)
  68. + goto err_btcoex;
  69. +
  70. ath9k_init_crypto(sc);
  71. - ath9k_init_channels_rates(sc);
  72. ath9k_init_misc(sc);
  73. return 0;
  74. @@ -784,6 +803,12 @@ static void ath9k_deinit_softc(struct at
  75. {
  76. int i = 0;
  77. + if (sc->sbands[IEEE80211_BAND_2GHZ].channels)
  78. + kfree(sc->sbands[IEEE80211_BAND_2GHZ].channels);
  79. +
  80. + if (sc->sbands[IEEE80211_BAND_5GHZ].channels)
  81. + kfree(sc->sbands[IEEE80211_BAND_5GHZ].channels);
  82. +
  83. if ((sc->btcoex.no_stomp_timer) &&
  84. sc->sc_ah->btcoex_hw.scheme == ATH_BTCOEX_CFG_3WIRE)
  85. ath_gen_timer_free(sc->sc_ah, sc->btcoex.no_stomp_timer);