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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. @@ -1213,6 +1213,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,8 @@ 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. + int err;
  67. brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
  68. if (!fw_cb || !code)
  69. @@ -548,9 +559,17 @@ int brcmf_fw_get_firmwares_pcie(struct d
  70. fwctx->domain_nr = domain_nr;
  71. fwctx->bus_nr = bus_nr;
  72. - return request_firmware_nowait(THIS_MODULE, true, code, dev,
  73. + init_completion(&completion);
  74. + fwctx->completion = &completion;
  75. +
  76. + err = request_firmware_nowait(THIS_MODULE, true, code, dev,
  77. GFP_KERNEL, fwctx,
  78. brcmf_fw_request_code_done);
  79. + if (!err)
  80. + wait_for_completion_timeout(fwctx->completion,
  81. + msecs_to_jiffies(5000));
  82. + fwctx->completion = NULL;
  83. + return err;
  84. }
  85. int brcmf_fw_get_firmwares(struct device *dev, u16 flags,