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
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.
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>
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(-)
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);
34 @@ -228,10 +228,10 @@ int brcmf_bus_get_memdump(struct brcmf_b
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)
42 - return bus->ops->get_fwname(bus->dev, chip, chiprev, fw_name);
43 + return bus->ops->get_fwname(bus->dev, ext, fw_name);
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
53 -static int brcmf_c_get_clm_name(struct brcmf_if *ifp, u8 *clm_name)
55 - struct brcmf_bus *bus = ifp->drvr->bus_if;
56 - u8 fw_name[BRCMF_FW_NAME_LEN];
61 - memset(fw_name, 0, BRCMF_FW_NAME_LEN);
62 - err = brcmf_bus_get_fwname(bus, bus->chip, bus->chiprev, fw_name);
64 - brcmf_err("get firmware name failed (%d)\n", err);
68 - /* generate CLM blob file name */
69 - ptr = strrchr(fw_name, '.');
75 - len = ptr - fw_name + 1;
76 - if (len + strlen(".clm_blob") > BRCMF_FW_NAME_LEN) {
79 - strlcpy(clm_name, fw_name, len);
80 - strlcat(clm_name, ".clm_blob", BRCMF_FW_NAME_LEN);
86 static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
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
95 brcmf_dbg(TRACE, "Enter\n");
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);
102 brcmf_err("get CLM blob file name failed (%d)\n", err);
106 - err = request_firmware(&clm, clm_name, dev);
107 + err = request_firmware(&clm, clm_name, bus->dev);
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",
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
120 -static int brcmf_pcie_get_fwname(struct device *dev, u32 chip, u32 chiprev,
123 +int brcmf_pcie_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
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;
129 + struct brcmf_fw_request *fwreq;
130 + struct brcmf_fw_name fwnames[] = {
134 - if (devinfo->fw_name[0] != '\0')
135 - strlcpy(fw_name, devinfo->fw_name, BRCMF_FW_NAME_LEN);
137 - ret = brcmf_fw_map_chip_to_name(chip, chiprev,
138 - brcmf_pcie_fwnames,
139 - ARRAY_SIZE(brcmf_pcie_fwnames),
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));
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)
160 -static int brcmf_sdio_get_fwname(struct device *dev, u32 chip, u32 chiprev,
163 +int brcmf_sdio_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
165 struct brcmf_bus *bus_if = dev_get_drvdata(dev);
166 - struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
168 + struct brcmf_fw_request *fwreq;
169 + struct brcmf_fw_name fwnames[] = {
173 - if (sdiodev->fw_name[0] != '\0')
174 - strlcpy(fw_name, sdiodev->fw_name, BRCMF_FW_NAME_LEN);
176 - ret = brcmf_fw_map_chip_to_name(chip, chiprev,
177 - brcmf_sdio_fwnames,
178 - ARRAY_SIZE(brcmf_sdio_fwnames),
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));
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);
199 -static int brcmf_usb_get_fwname(struct device *dev, u32 chip, u32 chiprev,
202 +int brcmf_usb_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
204 - struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev);
206 + struct brcmf_bus *bus = dev_get_drvdata(dev);
207 + struct brcmf_fw_request *fwreq;
208 + struct brcmf_fw_name fwnames[] = {
212 - if (devinfo->fw_name[0] != '\0')
213 - strlcpy(fw_name, devinfo->fw_name, BRCMF_FW_NAME_LEN);
215 - ret = brcmf_fw_map_chip_to_name(chip, chiprev,
217 - ARRAY_SIZE(brcmf_usb_fwnames),
219 + fwreq = brcmf_fw_alloc_request(bus->chip, bus->chiprev,
221 + ARRAY_SIZE(brcmf_usb_fwnames),
222 + fwnames, ARRAY_SIZE(fwnames));
231 static const struct brcmf_bus_ops brcmf_usb_bus_ops = {