mac80211: brcm: backport brcmfmac 5.2 patches
[openwrt/openwrt.git] / package / kernel / mac80211 / patches / brcm / 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 @@ -1436,6 +1436,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 @@ -442,6 +442,7 @@ struct brcmf_fw {
27 struct brcmf_fw_request *req;
28 u32 curpos;
29 void (*done)(struct device *dev, int err, struct brcmf_fw_request *req);
30 + struct completion *completion;
31 };
32
33 static void brcmf_fw_request_done(const struct firmware *fw, void *ctx);
34 @@ -649,6 +650,8 @@ static void brcmf_fw_request_done(const
35 fwctx->req = NULL;
36 }
37 fwctx->done(fwctx->dev, ret, fwctx->req);
38 + if (fwctx->completion)
39 + complete(fwctx->completion);
40 kfree(fwctx);
41 }
42
43 @@ -673,6 +676,8 @@ int brcmf_fw_get_firmwares(struct device
44 {
45 struct brcmf_fw_item *first = &req->items[0];
46 struct brcmf_fw *fwctx;
47 + struct completion completion;
48 + unsigned long time_left;
49 int ret;
50
51 brcmf_dbg(TRACE, "enter: dev=%s\n", dev_name(dev));
52 @@ -689,6 +694,9 @@ int brcmf_fw_get_firmwares(struct device
53 fwctx->dev = dev;
54 fwctx->req = req;
55 fwctx->done = fw_cb;
56 +
57 + init_completion(&completion);
58 + fwctx->completion = &completion;
59
60 ret = request_firmware_nowait(THIS_MODULE, true, first->path,
61 fwctx->dev, GFP_KERNEL, fwctx,
62 @@ -696,6 +704,12 @@ int brcmf_fw_get_firmwares(struct device
63 if (ret < 0)
64 brcmf_fw_request_done(NULL, fwctx);
65
66 +
67 + time_left = wait_for_completion_timeout(&completion,
68 + msecs_to_jiffies(5000));
69 + if (!time_left && fwctx)
70 + fwctx->completion = NULL;
71 +
72 return 0;
73 }
74