Commit bf7a7b37 authored by Arend Van Spriel's avatar Arend Van Spriel Committed by Kalle Valo

brcmfmac: add extension to .get_fwname() callbacks

This changes the bus layer api by having the caller provide an
extension. With this the callback can use brcmf_fw_alloc_request()
to get the needed firmware name.
Reviewed-by: default avatarHante Meuleman <hante.meuleman@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieter-paul.giesberts@broadcom.com>
Reviewed-by: default avatarFranky Lin <franky.lin@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 2baa3aae
...@@ -88,7 +88,7 @@ struct brcmf_bus_ops { ...@@ -88,7 +88,7 @@ struct brcmf_bus_ops {
void (*wowl_config)(struct device *dev, bool enabled); void (*wowl_config)(struct device *dev, bool enabled);
size_t (*get_ramsize)(struct device *dev); size_t (*get_ramsize)(struct device *dev);
int (*get_memdump)(struct device *dev, void *data, size_t len); int (*get_memdump)(struct device *dev, void *data, size_t len);
int (*get_fwname)(struct device *dev, uint chip, uint chiprev, int (*get_fwname)(struct device *dev, const char *ext,
unsigned char *fw_name); unsigned char *fw_name);
}; };
...@@ -228,10 +228,10 @@ int brcmf_bus_get_memdump(struct brcmf_bus *bus, void *data, size_t len) ...@@ -228,10 +228,10 @@ int brcmf_bus_get_memdump(struct brcmf_bus *bus, void *data, size_t len)
} }
static inline static inline
int brcmf_bus_get_fwname(struct brcmf_bus *bus, uint chip, uint chiprev, int brcmf_bus_get_fwname(struct brcmf_bus *bus, const char *ext,
unsigned char *fw_name) unsigned char *fw_name)
{ {
return bus->ops->get_fwname(bus->dev, chip, chiprev, fw_name); return bus->ops->get_fwname(bus->dev, ext, fw_name);
} }
/* /*
......
...@@ -125,42 +125,9 @@ static int brcmf_c_download(struct brcmf_if *ifp, u16 flag, ...@@ -125,42 +125,9 @@ static int brcmf_c_download(struct brcmf_if *ifp, u16 flag,
return err; return err;
} }
static int brcmf_c_get_clm_name(struct brcmf_if *ifp, u8 *clm_name)
{
struct brcmf_bus *bus = ifp->drvr->bus_if;
u8 fw_name[BRCMF_FW_NAME_LEN];
u8 *ptr;
size_t len;
s32 err;
memset(fw_name, 0, BRCMF_FW_NAME_LEN);
err = brcmf_bus_get_fwname(bus, bus->chip, bus->chiprev, fw_name);
if (err) {
brcmf_err("get firmware name failed (%d)\n", err);
goto done;
}
/* generate CLM blob file name */
ptr = strrchr(fw_name, '.');
if (!ptr) {
err = -ENOENT;
goto done;
}
len = ptr - fw_name + 1;
if (len + strlen(".clm_blob") > BRCMF_FW_NAME_LEN) {
err = -E2BIG;
} else {
strlcpy(clm_name, fw_name, len);
strlcat(clm_name, ".clm_blob", BRCMF_FW_NAME_LEN);
}
done:
return err;
}
static int brcmf_c_process_clm_blob(struct brcmf_if *ifp) static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
{ {
struct device *dev = ifp->drvr->bus_if->dev; struct brcmf_bus *bus = ifp->drvr->bus_if;
struct brcmf_dload_data_le *chunk_buf; struct brcmf_dload_data_le *chunk_buf;
const struct firmware *clm = NULL; const struct firmware *clm = NULL;
u8 clm_name[BRCMF_FW_NAME_LEN]; u8 clm_name[BRCMF_FW_NAME_LEN];
...@@ -173,16 +140,16 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp) ...@@ -173,16 +140,16 @@ static int brcmf_c_process_clm_blob(struct brcmf_if *ifp)
brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(TRACE, "Enter\n");
memset(clm_name, 0, BRCMF_FW_NAME_LEN); memset(clm_name, 0, sizeof(clm_name));
err = brcmf_c_get_clm_name(ifp, clm_name); err = brcmf_bus_get_fwname(bus, ".clm_blob", clm_name);
if (err) { if (err) {
brcmf_err("get CLM blob file name failed (%d)\n", err); brcmf_err("get CLM blob file name failed (%d)\n", err);
return err; return err;
} }
err = request_firmware(&clm, clm_name, dev); err = request_firmware(&clm, clm_name, bus->dev);
if (err) { if (err) {
brcmf_info("no clm_blob available(err=%d), device may have limited channels available\n", brcmf_info("no clm_blob available (err=%d), device may have limited channels available\n",
err); err);
return 0; return 0;
} }
......
...@@ -1350,23 +1350,24 @@ static int brcmf_pcie_get_memdump(struct device *dev, void *data, size_t len) ...@@ -1350,23 +1350,24 @@ static int brcmf_pcie_get_memdump(struct device *dev, void *data, size_t len)
return 0; return 0;
} }
static int brcmf_pcie_get_fwname(struct device *dev, u32 chip, u32 chiprev, static
u8 *fw_name) int brcmf_pcie_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
{ {
struct brcmf_bus *bus_if = dev_get_drvdata(dev); struct brcmf_bus *bus_if = dev_get_drvdata(dev);
struct brcmf_pciedev *buspub = bus_if->bus_priv.pcie; struct brcmf_fw_request *fwreq;
struct brcmf_pciedev_info *devinfo = buspub->devinfo; struct brcmf_fw_name fwnames[] = {
int ret = 0; { ext, fw_name },
};
if (devinfo->fw_name[0] != '\0') fwreq = brcmf_fw_alloc_request(bus_if->chip, bus_if->chiprev,
strlcpy(fw_name, devinfo->fw_name, BRCMF_FW_NAME_LEN); brcmf_pcie_fwnames,
else ARRAY_SIZE(brcmf_pcie_fwnames),
ret = brcmf_fw_map_chip_to_name(chip, chiprev, fwnames, ARRAY_SIZE(fwnames));
brcmf_pcie_fwnames, if (!fwreq)
ARRAY_SIZE(brcmf_pcie_fwnames), return -ENOMEM;
fw_name, NULL);
return ret; kfree(fwreq);
return 0;
} }
static const struct brcmf_bus_ops brcmf_pcie_bus_ops = { static const struct brcmf_bus_ops brcmf_pcie_bus_ops = {
......
...@@ -4000,22 +4000,24 @@ brcmf_sdio_watchdog(struct timer_list *t) ...@@ -4000,22 +4000,24 @@ brcmf_sdio_watchdog(struct timer_list *t)
} }
} }
static int brcmf_sdio_get_fwname(struct device *dev, u32 chip, u32 chiprev, static
u8 *fw_name) int brcmf_sdio_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
{ {
struct brcmf_bus *bus_if = dev_get_drvdata(dev); struct brcmf_bus *bus_if = dev_get_drvdata(dev);
struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; struct brcmf_fw_request *fwreq;
int ret = 0; struct brcmf_fw_name fwnames[] = {
{ ext, fw_name },
};
if (sdiodev->fw_name[0] != '\0') fwreq = brcmf_fw_alloc_request(bus_if->chip, bus_if->chiprev,
strlcpy(fw_name, sdiodev->fw_name, BRCMF_FW_NAME_LEN); brcmf_sdio_fwnames,
else ARRAY_SIZE(brcmf_sdio_fwnames),
ret = brcmf_fw_map_chip_to_name(chip, chiprev, fwnames, ARRAY_SIZE(fwnames));
brcmf_sdio_fwnames, if (!fwreq)
ARRAY_SIZE(brcmf_sdio_fwnames), return -ENOMEM;
fw_name, NULL);
return ret; kfree(fwreq);
return 0;
} }
static const struct brcmf_bus_ops brcmf_sdio_bus_ops = { static const struct brcmf_bus_ops brcmf_sdio_bus_ops = {
......
...@@ -1128,21 +1128,24 @@ static void brcmf_usb_wowl_config(struct device *dev, bool enabled) ...@@ -1128,21 +1128,24 @@ static void brcmf_usb_wowl_config(struct device *dev, bool enabled)
device_set_wakeup_enable(devinfo->dev, false); device_set_wakeup_enable(devinfo->dev, false);
} }
static int brcmf_usb_get_fwname(struct device *dev, u32 chip, u32 chiprev, static
u8 *fw_name) int brcmf_usb_get_fwname(struct device *dev, const char *ext, u8 *fw_name)
{ {
struct brcmf_usbdev_info *devinfo = brcmf_usb_get_businfo(dev); struct brcmf_bus *bus = dev_get_drvdata(dev);
int ret = 0; struct brcmf_fw_request *fwreq;
struct brcmf_fw_name fwnames[] = {
{ ext, fw_name },
};
if (devinfo->fw_name[0] != '\0') fwreq = brcmf_fw_alloc_request(bus->chip, bus->chiprev,
strlcpy(fw_name, devinfo->fw_name, BRCMF_FW_NAME_LEN); brcmf_usb_fwnames,
else ARRAY_SIZE(brcmf_usb_fwnames),
ret = brcmf_fw_map_chip_to_name(chip, chiprev, fwnames, ARRAY_SIZE(fwnames));
brcmf_usb_fwnames, if (!fwreq)
ARRAY_SIZE(brcmf_usb_fwnames), return -ENOMEM;
fw_name, NULL);
return ret; kfree(fwreq);
return 0;
} }
static const struct brcmf_bus_ops brcmf_usb_bus_ops = { static const struct brcmf_bus_ops brcmf_usb_bus_ops = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment