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
5 Content-Type: text/plain; charset=UTF-8
6 Content-Transfer-Encoding: 8bit
8 This is needed by OpenWrt which expects all PHYs to be created after
9 module loads successfully.
11 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
14 --- a/drivers/net/wireless/brcm80211/brcmfmac/core.c
15 +++ b/drivers/net/wireless/brcm80211/brcmfmac/core.c
16 @@ -1213,6 +1213,7 @@ static int __init brcmfmac_module_init(v
18 if (!schedule_work(&brcmf_driver_work))
20 + flush_work(&brcmf_driver_work);
24 --- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
25 +++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
26 @@ -422,13 +422,14 @@ struct brcmf_fw {
28 void (*done)(struct device *dev, const struct firmware *fw,
29 void *nvram_image, u32 nvram_len);
30 + struct completion *completion;
33 static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
35 struct brcmf_fw *fwctx = ctx;
36 #if IS_ENABLED(CONFIG_BCM47XX_NVRAM)
37 - const u8 *bcm47xx_nvram = NULL;
38 + u8 *bcm47xx_nvram = NULL;
39 size_t bcm47xx_nvram_len;
41 const u8 *data = NULL;
42 @@ -468,6 +469,8 @@ static void brcmf_fw_request_nvram_done(
45 fwctx->done(fwctx->dev, fwctx->code, nvram, nvram_length);
46 + if (fwctx->completion)
47 + complete(fwctx->completion);
51 @@ -475,6 +478,8 @@ fail:
52 brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
53 release_firmware(fwctx->code);
54 device_release_driver(fwctx->dev);
55 + if (fwctx->completion)
56 + complete(fwctx->completion);
60 @@ -490,6 +495,8 @@ static void brcmf_fw_request_code_done(c
61 /* only requested code so done here */
62 if (!(fwctx->flags & BRCMF_FW_REQUEST_NVRAM)) {
63 fwctx->done(fwctx->dev, fw, NULL, 0);
64 + if (fwctx->completion)
65 + complete(fwctx->completion);
69 @@ -504,6 +511,8 @@ static void brcmf_fw_request_code_done(c
70 /* when nvram is optional call .done() callback here */
71 if (fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL) {
72 fwctx->done(fwctx->dev, fw, NULL, 0);
73 + if (fwctx->completion)
74 + complete(fwctx->completion);
78 @@ -513,6 +522,8 @@ static void brcmf_fw_request_code_done(c
80 brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
81 device_release_driver(fwctx->dev);
82 + if (fwctx->completion)
83 + complete(fwctx->completion);
87 @@ -524,6 +535,8 @@ int brcmf_fw_get_firmwares_pcie(struct d
88 u16 domain_nr, u16 bus_nr)
90 struct brcmf_fw *fwctx;
91 + struct completion completion;
94 brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
96 @@ -544,9 +557,17 @@ int brcmf_fw_get_firmwares_pcie(struct d
97 fwctx->domain_nr = domain_nr;
98 fwctx->bus_nr = bus_nr;
100 - return request_firmware_nowait(THIS_MODULE, true, code, dev,
101 + init_completion(&completion);
102 + fwctx->completion = &completion;
104 + err = request_firmware_nowait(THIS_MODULE, true, code, dev,
106 brcmf_fw_request_code_done);
108 + wait_for_completion_timeout(fwctx->completion,
109 + msecs_to_jiffies(5000));
110 + fwctx->completion = NULL;
114 int brcmf_fw_get_firmwares(struct device *dev, u16 flags,