mac80211: backport brcmfmac fixes from 4.16
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / 860-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/broadcom/brcm80211/brcmfmac/core.c
15 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
16 @@ -1295,6 +1295,7 @@ int __init brcmf_core_init(void)
17 {
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/broadcom/brcm80211/brcmfmac/firmware.c
25 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
26 @@ -444,6 +444,7 @@ struct brcmf_fw {
27 u16 bus_nr;
28 void (*done)(struct device *dev, int err, 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 @@ -478,6 +479,8 @@ static void brcmf_fw_request_nvram_done(
35 goto fail;
36
37 fwctx->done(fwctx->dev, 0, fwctx->code, nvram, nvram_length);
38 + if (fwctx->completion)
39 + complete(fwctx->completion);
40 kfree(fwctx);
41 return;
42
43 @@ -485,6 +488,8 @@ fail:
44 brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
45 release_firmware(fwctx->code);
46 fwctx->done(fwctx->dev, -ENOENT, NULL, NULL, 0);
47 + if (fwctx->completion)
48 + complete(fwctx->completion);
49 kfree(fwctx);
50 }
51
52 @@ -516,6 +521,8 @@ fail:
53 brcmf_dbg(TRACE, "failed: dev=%s\n", dev_name(fwctx->dev));
54 done:
55 fwctx->done(fwctx->dev, ret, fw, NULL, 0);
56 + if (fwctx->completion)
57 + complete(fwctx->completion);
58 kfree(fwctx);
59 }
60
61 @@ -527,6 +534,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
68 brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
69 if (!fw_cb || !code)
70 @@ -547,9 +556,17 @@ int brcmf_fw_get_firmwares_pcie(struct d
71 fwctx->domain_nr = domain_nr;
72 fwctx->bus_nr = bus_nr;
73
74 - return request_firmware_nowait(THIS_MODULE, true, code, dev,
75 + init_completion(&completion);
76 + fwctx->completion = &completion;
77 +
78 + err = request_firmware_nowait(THIS_MODULE, true, code, dev,
79 GFP_KERNEL, fwctx,
80 brcmf_fw_request_code_done);
81 + if (!err)
82 + wait_for_completion_timeout(fwctx->completion,
83 + msecs_to_jiffies(5000));
84 + fwctx->completion = NULL;
85 + return err;
86 }
87
88 int brcmf_fw_get_firmwares(struct device *dev, u16 flags,