391229a865112e91f3311b138260bcfe6a0eb76d
[openwrt/staging/linusw.git] /
1 From bf7a7b37f6ef5090a2bae7e7ae23cd26b741cca4 Mon Sep 17 00:00:00 2001
2 From: Arend Van Spriel <arend.vanspriel@broadcom.com>
3 Date: Thu, 22 Mar 2018 21:28:28 +0100
4 Subject: [PATCH] brcmfmac: add extension to .get_fwname() callbacks
5
6 This changes the bus layer api by having the caller provide an
7 extension. With this the callback can use brcmf_fw_alloc_request()
8 to get the needed firmware name.
9
10 Reviewed-by: Hante Meuleman <hante.meuleman@broadcom.com>
11 Reviewed-by: Pieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
12 Reviewed-by: Franky Lin <franky.lin@broadcom.com>
13 Signed-off-by: Arend van Spriel <arend.vanspriel@broadcom.com>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 ---
16 .../net/wireless/broadcom/brcm80211/brcmfmac/bus.h | 6 +--
17 .../wireless/broadcom/brcm80211/brcmfmac/common.c | 43 +++-------------------
18 .../wireless/broadcom/brcm80211/brcmfmac/pcie.c | 27 +++++++-------
19 .../wireless/broadcom/brcm80211/brcmfmac/sdio.c | 26 +++++++------
20 .../net/wireless/broadcom/brcm80211/brcmfmac/usb.c | 27 ++++++++------
21 5 files changed, 51 insertions(+), 78 deletions(-)
22
23 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
24 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bus.h
25 @@ -88,7 +88,7 @@ struct brcmf_bus_ops {
26 void (*wowl_config)(struct device *dev, bool enabled);
27 size_t (*get_ramsize)(struct device *dev);
28 int (*get_memdump)(struct device *dev, void *data, size_t len);
29 - int (*get_fwname)(struct device *dev, uint chip, uint chiprev,
30 + int (*get_fwname)(struct device *dev, const char *ext,
31 unsigned char *fw_name);
32 };
33
34 @@ -228,10 +228,10 @@ int brcmf_bus_get_memdump(struct brcmf_b
35 }
36
37 static inline
38 -int brcmf_bus_get_fwname(struct brcmf_bus *bus, uint chip, uint chiprev,
39 +int brcmf_bus_get_fwname(struct brcmf_bus *bus, const char *ext,
40 unsigned char *fw_name)
41 {
42 - return bus->ops->get_fwname(bus->dev, chip, chiprev, fw_name);
43 + return bus->ops->get_fwname(bus->dev, ext, fw_name);
44 }
45
46 /*
47 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
48 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
49 @@ -129,42 +129,9 @@ static int brcmf_c_download(struct brcmf
50 return err;
51 }
52
53 -static int brcmf_c_get_clm_name(struct brcmf_if *ifp, u8 *clm_name)
54 -{
55 - struct brcmf_bus *bus = ifp->drvr->bus_if;
56 - u8 fw_name[BRCMF_FW_NAME_LEN];
57 - u8 *ptr;
58 - size_t len;
59 - s32 err;
60 -
61 - memset(fw_name, 0, BRCMF_FW_NAME_LEN);
62 - err = brcmf_bus_get_fwname(bus, bus->chip, bus->chiprev, fw_name);
63 - if (err) {
64 - brcmf_err("get firmware name failed (%d)\n", err);
65 - goto done;
66 - }
67 -
68 - /* generate CLM blob file name */
69 - ptr = strrchr(fw_name, '.');
70 - if (!ptr) {
71 - err = -ENOENT;
72 - goto done;
73 - }
74 -
75 - len = ptr - fw_name + 1;
76 - if (len + strlen(".clm_blob") > BRCMF_FW_NAME_LEN) {
77 - err = -E2BIG;
78 - } else {
79 - strlcpy(clm_name, fw_name, len);
80 - strlcat(clm_name, ".clm_blob", BRCMF_FW_NAME_LEN);
81 - }
82 -done:
83 - return err;
84 -}
85 -
86 static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
87 {
88 - struct device *dev = ifp->drvr->bus_if->dev;
89 + struct brcmf_bus *bus = ifp->drvr->bus_if;
90 struct brcmf_dload_data_le *chunk_buf;
91 const struct firmware *clm = NULL;
92 u8 clm_name[BRCMF_FW_NAME_LEN];
93 @@ -177,16 +144,16 @@ static int brcmf_c_process_clm_blob(stru
94
95 brcmf_dbg(TRACE, "Enter\n");
96
97 - memset(clm_name, 0, BRCMF_FW_NAME_LEN);
98 - err = brcmf_c_get_clm_name(ifp, clm_name);
99 + memset(clm_name, 0, sizeof(clm_name));
100 + err = brcmf_bus_get_fwname(bus, ".clm_blob", clm_name);
101 if (err) {
102 brcmf_err("get CLM blob file name failed (%d)\n", err);
103 return err;
104 }
105
106 - err = request_firmware(&clm, clm_name, dev);
107 + err = request_firmware(&clm, clm_name, bus->dev);
108 if (err) {
109 - brcmf_info("no clm_blob available(err=%d), device may have limited channels available\n",
110 + brcmf_info("no clm_blob available (err=%d), device may have limited channels available\n",
111 err);
112 return 0;
113 }
114 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
115 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
116 @@ -1350,23 +1350,24 @@ static int brcmf_pcie_get_memdump(struct
117 return 0;
118 }
119
120 -static int brcmf_pcie_get_fwname(struct device *dev, u32 chip, u32 chiprev,
121 - u8 *fw_name)
122 +static
123 +int brcmf_pcie_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
124 {
125 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
126 - struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie;
127 - struct brcmf_pciedev_info *devinfo = buspub->devinfo;
128 - int ret = 0;
129 + struct brcmf_fw_request *fwreq;
130 + struct brcmf_fw_name fwnames[] = {
131 + { ext, fw_name },
132 + };
133
134 - if (devinfo->fw_name[0] != '\0')
135 - strlcpy(fw_name, devinfo->fw_name, BRCMF_FW_NAME_LEN);
136 - else
137 - ret = brcmf_fw_map_chip_to_name(chip, chiprev,
138 - brcmf_pcie_fwnames,
139 - ARRAY_SIZE(brcmf_pcie_fwnames),
140 - fw_name, NULL);
141 + fwreq = brcmf_fw_alloc_request(bus_if->chip, bus_if->chiprev,
142 + brcmf_pcie_fwnames,
143 + ARRAY_SIZE(brcmf_pcie_fwnames),
144 + fwnames, ARRAY_SIZE(fwnames));
145 + if (!fwreq)
146 + return -ENOMEM;
147
148 - return ret;
149 + kfree(fwreq);
150 + return 0;
151 }
152
153 static const struct brcmf_bus_ops brcmf_pcie_bus_ops = {
154 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
155 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/sdio.c
156 @@ -4000,22 +4000,24 @@ brcmf_sdio_watchdog(unsigned long data)
157 }
158 }
159
160 -static int brcmf_sdio_get_fwname(struct device *dev, u32 chip, u32 chiprev,
161 - u8 *fw_name)
162 +static
163 +int brcmf_sdio_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
164 {
165 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
166 - struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
167 - int ret = 0;
168 + struct brcmf_fw_request *fwreq;
169 + struct brcmf_fw_name fwnames[] = {
170 + { ext, fw_name },
171 + };
172
173 - if (sdiodev->fw_name[0] != '\0')
174 - strlcpy(fw_name, sdiodev->fw_name, BRCMF_FW_NAME_LEN);
175 - else
176 - ret = brcmf_fw_map_chip_to_name(chip, chiprev,
177 - brcmf_sdio_fwnames,
178 - ARRAY_SIZE(brcmf_sdio_fwnames),
179 - fw_name, NULL);
180 + fwreq = brcmf_fw_alloc_request(bus_if->chip, bus_if->chiprev,
181 + brcmf_sdio_fwnames,
182 + ARRAY_SIZE(brcmf_sdio_fwnames),
183 + fwnames, ARRAY_SIZE(fwnames));
184 + if (!fwreq)
185 + return -ENOMEM;
186
187 - return ret;
188 + kfree(fwreq);
189 + return 0;
190 }
191
192 static const struct brcmf_bus_ops brcmf_sdio_bus_ops = {
193 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
194 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/usb.c
195 @@ -1128,21 +1128,24 @@ static void brcmf_usb_wowl_config(struct
196 device_set_wakeup_enable(devinfo->dev, false);
197 }
198
199 -static int brcmf_usb_get_fwname(struct device *dev, u32 chip, u32 chiprev,
200 - u8 *fw_name)
201 +static
202 +int brcmf_usb_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
203 {
204 - struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);
205 - int ret = 0;
206 + struct brcmf_bus *bus = dev_get_drvdata(dev);
207 + struct brcmf_fw_request *fwreq;
208 + struct brcmf_fw_name fwnames[] = {
209 + { ext, fw_name },
210 + };
211
212 - if (devinfo->fw_name[0] != '\0')
213 - strlcpy(fw_name, devinfo->fw_name, BRCMF_FW_NAME_LEN);
214 - else
215 - ret = brcmf_fw_map_chip_to_name(chip, chiprev,
216 - brcmf_usb_fwnames,
217 - ARRAY_SIZE(brcmf_usb_fwnames),
218 - fw_name, NULL);
219 + fwreq = brcmf_fw_alloc_request(bus->chip, bus->chiprev,
220 + brcmf_usb_fwnames,
221 + ARRAY_SIZE(brcmf_usb_fwnames),
222 + fwnames, ARRAY_SIZE(fwnames));
223 + if (!fwreq)
224 + return -ENOMEM;
225
226 - return ret;
227 + kfree(fwreq);
228 + return 0;
229 }
230
231 static const struct brcmf_bus_ops brcmf_usb_bus_ops = {