860-brcmfmac-register-wiphy-s-during-module_init.patch 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <zajec5@gmail.com>
  2. Date: Mon, 8 Jun 2015 16:11:40 +0200
  3. Subject: [PATCH] brcmfmac: register wiphy(s) during module_init
  4. MIME-Version: 1.0
  5. Content-Type: text/plain; charset=UTF-8
  6. Content-Transfer-Encoding: 8bit
  7. This is needed by OpenWrt which expects all PHYs to be created after
  8. module loads successfully.
  9. Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
  10. ---
  11. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  12. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  13. @@ -1409,6 +1409,7 @@ int __init brcmf_core_init(void)
  14. {
  15. if (!schedule_work(&brcmf_driver_work))
  16. return -EBUSY;
  17. + flush_work(&brcmf_driver_work);
  18. return 0;
  19. }
  20. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
  21. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
  22. @@ -444,6 +444,7 @@ struct brcmf_fw {
  23. u16 bus_nr;
  24. void (*done)(struct device *dev, const struct firmware *fw,
  25. void *nvram_image, u32 nvram_len);
  26. + struct completion *completion;
  27. };
  28. static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
  29. @@ -478,6 +479,8 @@ static void brcmf_fw_request_nvram_done(
  30. goto fail;
  31. fwctx->done(fwctx->dev, fwctx->code, nvram, nvram_length);
  32. + if (fwctx->completion)
  33. + complete(fwctx->completion);
  34. kfree(fwctx);
  35. return;
  36. @@ -485,6 +488,8 @@ fail:
  37. brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
  38. release_firmware(fwctx->code);
  39. device_release_driver(fwctx->dev);
  40. + if (fwctx->completion)
  41. + complete(fwctx->completion);
  42. kfree(fwctx);
  43. }
  44. @@ -500,6 +505,8 @@ static void brcmf_fw_request_code_done(c
  45. /* only requested code so done here */
  46. if (!(fwctx->flags & BRCMF_FW_REQUEST_NVRAM)) {
  47. fwctx->done(fwctx->dev, fw, NULL, 0);
  48. + if (fwctx->completion)
  49. + complete(fwctx->completion);
  50. kfree(fwctx);
  51. return;
  52. }
  53. @@ -517,6 +524,8 @@ static void brcmf_fw_request_code_done(c
  54. fail:
  55. brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
  56. device_release_driver(fwctx->dev);
  57. + if (fwctx->completion)
  58. + complete(fwctx->completion);
  59. kfree(fwctx);
  60. }
  61. @@ -528,6 +537,9 @@ int brcmf_fw_get_firmwares_pcie(struct d
  62. u16 domain_nr, u16 bus_nr)
  63. {
  64. struct brcmf_fw *fwctx;
  65. + struct completion completion;
  66. + unsigned long time_left;
  67. + int err;
  68. brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
  69. if (!fw_cb || !code)
  70. @@ -548,9 +560,20 @@ int brcmf_fw_get_firmwares_pcie(struct d
  71. fwctx->domain_nr = domain_nr;
  72. fwctx->bus_nr = bus_nr;
  73. - return request_firmware_nowait(THIS_MODULE, true, code, dev,
  74. + init_completion(&completion);
  75. + fwctx->completion = &completion;
  76. +
  77. + err = request_firmware_nowait(THIS_MODULE, true, code, dev,
  78. GFP_KERNEL, fwctx,
  79. brcmf_fw_request_code_done);
  80. + if (!err) {
  81. + time_left = wait_for_completion_timeout(&completion,
  82. + msecs_to_jiffies(5000));
  83. + if (!time_left && fwctx)
  84. + fwctx->completion = NULL;
  85. + }
  86. +
  87. + return err;
  88. }
  89. int brcmf_fw_get_firmwares(struct device *dev, u16 flags,