[OpenWrt-Devel] [PATCH RFC] brcmfmac: register wiphy(s) during module_init

Rafał Miłecki zajec5 at gmail.com
Sun May 31 18:08:21 EDT 2015


This is needed by OpenWrt which expects all PHYs to be created after
module loads successfully.

Signed-off-by: Rafał Miłecki <zajec5 at gmail.com>
---
 drivers/net/wireless/brcm80211/brcmfmac/core.c     |  1 +
 drivers/net/wireless/brcm80211/brcmfmac/firmware.c | 13 ++++++++++++-
 2 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/brcm80211/brcmfmac/core.c b/drivers/net/wireless/brcm80211/brcmfmac/core.c
index 538d695..c436cc8 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/core.c
@@ -1189,6 +1189,7 @@ static int __init brcmfmac_module_init(void)
 #endif
 	if (!schedule_work(&brcmf_driver_work))
 		return -EBUSY;
+	flush_work(&brcmf_driver_work);
 
 	return 0;
 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
index fdafa79..b6de504 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/firmware.c
@@ -419,6 +419,7 @@ struct brcmf_fw {
 	u16 bus_nr;
 	void (*done)(struct device *dev, const struct firmware *fw,
 		     void *nvram_image, u32 nvram_len);
+	struct completion completion;
 };
 
 static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
@@ -440,6 +441,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
 	}
 
 	fwctx->done(fwctx->dev, fwctx->code, nvram, nvram_length);
+	complete(&fwctx->completion);
 	kfree(fwctx);
 	return;
 
@@ -462,6 +464,7 @@ static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx)
 	/* only requested code so done here */
 	if (!(fwctx->flags & BRCMF_FW_REQUEST_NVRAM)) {
 		fwctx->done(fwctx->dev, fw, NULL, 0);
+		complete(&fwctx->completion);
 		kfree(fwctx);
 		return;
 	}
@@ -476,6 +479,7 @@ static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx)
 	/* when nvram is optional call .done() callback here */
 	if (fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL) {
 		fwctx->done(fwctx->dev, fw, NULL, 0);
+		complete(&fwctx->completion);
 		kfree(fwctx);
 		return;
 	}
@@ -485,6 +489,7 @@ static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx)
 fail:
 	brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
 	device_release_driver(fwctx->dev);
+	complete(&fwctx->completion);
 	kfree(fwctx);
 }
 
@@ -496,6 +501,7 @@ int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags,
 				u16 domain_nr, u16 bus_nr)
 {
 	struct brcmf_fw *fwctx;
+	int err;
 
 	brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
 	if (!fw_cb || !code)
@@ -515,10 +521,15 @@ int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags,
 		fwctx->nvram_name = nvram;
 	fwctx->domain_nr = domain_nr;
 	fwctx->bus_nr = bus_nr;
+	init_completion(&fwctx->completion);
 
-	return request_firmware_nowait(THIS_MODULE, true, code, dev,
+	err = request_firmware_nowait(THIS_MODULE, true, code, dev,
 				       GFP_KERNEL, fwctx,
 				       brcmf_fw_request_code_done);
+	if (!err)
+		wait_for_completion_timeout(&fwctx->completion,
+					    msecs_to_jiffies(5000));
+	return err;
 }
 
 int brcmf_fw_get_firmwares(struct device *dev, u16 flags,
-- 
1.8.4.5
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list