685a5f90c2a64ced7b687eda47871b23290f992d
[openwrt/staging/chunkeey.git] / package / kernel / mac80211 / patches / 861-brcmfmac-register-wiphy-s-during-module_init.patch
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
8 This is needed by OpenWrt which expects all PHYs to be created after
9 module loads successfully.
10
11 Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
12 ---
13
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
17 #endif
18 if (!schedule_work(&brcmf_driver_work))
19 return -EBUSY;
20 + flush_work(&brcmf_driver_work);
21
22 return 0;
23 }
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 {
27 u16 bus_nr;
28 void (*done)(struct device *dev, const struct firmware *fw,
29 void *nvram_image, u32 nvram_len);
30 + struct completion *completion;
31 };
32
33 static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
34 {
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;
40 #endif
41 const u8 *data = NULL;
42 @@ -468,6 +469,8 @@ static void brcmf_fw_request_nvram_done(
43 }
44
45 fwctx->done(fwctx->dev, fwctx->code, nvram, nvram_length);
46 + if (fwctx->completion)
47 + complete(fwctx->completion);
48 kfree(fwctx);
49 return;
50
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);
57 kfree(fwctx);
58 }
59
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);
66 kfree(fwctx);
67 return;
68 }
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);
75 kfree(fwctx);
76 return;
77 }
78 @@ -513,6 +522,8 @@ static void brcmf_fw_request_code_done(c
79 fail:
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);
84 kfree(fwctx);
85 }
86
87 @@ -524,6 +535,8 @@ int brcmf_fw_get_firmwares_pcie(struct d
88 u16 domain_nr, u16 bus_nr)
89 {
90 struct brcmf_fw *fwctx;
91 + struct completion completion;
92 + int err;
93
94 brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
95 if (!fw_cb || !code)
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;
99
100 - return request_firmware_nowait(THIS_MODULE, true, code, dev,
101 + init_completion(&completion);
102 + fwctx->completion = &completion;
103 +
104 + err = request_firmware_nowait(THIS_MODULE, true, code, dev,
105 GFP_KERNEL, fwctx,
106 brcmf_fw_request_code_done);
107 + if (!err)
108 + wait_for_completion_timeout(fwctx->completion,
109 + msecs_to_jiffies(5000));
110 + fwctx->completion = NULL;
111 + return err;
112 }
113
114 int brcmf_fw_get_firmwares(struct device *dev, u16 flags,