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

brcmfmac: add parameter to pass error code in firmware callback

Extend the parameters in the firmware callback so it can be called
upon success and failure. This allows the caller to properly clear
all resources in the failure path. Right now the error code is
always zero, ie. success.

Cc: stable@vger.kernel.org # 4.9.x-
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 dc89481b
...@@ -442,7 +442,7 @@ struct brcmf_fw { ...@@ -442,7 +442,7 @@ struct brcmf_fw {
const char *nvram_name; const char *nvram_name;
u16 domain_nr; u16 domain_nr;
u16 bus_nr; u16 bus_nr;
void (*done)(struct device *dev, const struct firmware *fw, void (*done)(struct device *dev, int err, const struct firmware *fw,
void *nvram_image, u32 nvram_len); void *nvram_image, u32 nvram_len);
}; };
...@@ -477,7 +477,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx) ...@@ -477,7 +477,7 @@ static void brcmf_fw_request_nvram_done(const struct firmware *fw, void *ctx)
if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL)) if (!nvram && !(fwctx->flags & BRCMF_FW_REQ_NV_OPTIONAL))
goto fail; goto fail;
fwctx->done(fwctx->dev, fwctx->code, nvram, nvram_length); fwctx->done(fwctx->dev, 0, fwctx->code, nvram, nvram_length);
kfree(fwctx); kfree(fwctx);
return; return;
...@@ -499,7 +499,7 @@ static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx) ...@@ -499,7 +499,7 @@ static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx)
/* only requested code so done here */ /* only requested code so done here */
if (!(fwctx->flags & BRCMF_FW_REQUEST_NVRAM)) { if (!(fwctx->flags & BRCMF_FW_REQUEST_NVRAM)) {
fwctx->done(fwctx->dev, fw, NULL, 0); fwctx->done(fwctx->dev, 0, fw, NULL, 0);
kfree(fwctx); kfree(fwctx);
return; return;
} }
...@@ -522,7 +522,7 @@ static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx) ...@@ -522,7 +522,7 @@ static void brcmf_fw_request_code_done(const struct firmware *fw, void *ctx)
int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags, int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags,
const char *code, const char *nvram, const char *code, const char *nvram,
void (*fw_cb)(struct device *dev, void (*fw_cb)(struct device *dev, int err,
const struct firmware *fw, const struct firmware *fw,
void *nvram_image, u32 nvram_len), void *nvram_image, u32 nvram_len),
u16 domain_nr, u16 bus_nr) u16 domain_nr, u16 bus_nr)
...@@ -555,7 +555,7 @@ int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags, ...@@ -555,7 +555,7 @@ int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags,
int brcmf_fw_get_firmwares(struct device *dev, u16 flags, int brcmf_fw_get_firmwares(struct device *dev, u16 flags,
const char *code, const char *nvram, const char *code, const char *nvram,
void (*fw_cb)(struct device *dev, void (*fw_cb)(struct device *dev, int err,
const struct firmware *fw, const struct firmware *fw,
void *nvram_image, u32 nvram_len)) void *nvram_image, u32 nvram_len))
{ {
......
...@@ -73,13 +73,13 @@ void brcmf_fw_nvram_free(void *nvram); ...@@ -73,13 +73,13 @@ void brcmf_fw_nvram_free(void *nvram);
*/ */
int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags, int brcmf_fw_get_firmwares_pcie(struct device *dev, u16 flags,
const char *code, const char *nvram, const char *code, const char *nvram,
void (*fw_cb)(struct device *dev, void (*fw_cb)(struct device *dev, int err,
const struct firmware *fw, const struct firmware *fw,
void *nvram_image, u32 nvram_len), void *nvram_image, u32 nvram_len),
u16 domain_nr, u16 bus_nr); u16 domain_nr, u16 bus_nr);
int brcmf_fw_get_firmwares(struct device *dev, u16 flags, int brcmf_fw_get_firmwares(struct device *dev, u16 flags,
const char *code, const char *nvram, const char *code, const char *nvram,
void (*fw_cb)(struct device *dev, void (*fw_cb)(struct device *dev, int err,
const struct firmware *fw, const struct firmware *fw,
void *nvram_image, u32 nvram_len)); void *nvram_image, u32 nvram_len));
......
...@@ -1650,16 +1650,23 @@ static const struct brcmf_buscore_ops brcmf_pcie_buscore_ops = { ...@@ -1650,16 +1650,23 @@ static const struct brcmf_buscore_ops brcmf_pcie_buscore_ops = {
.write32 = brcmf_pcie_buscore_write32, .write32 = brcmf_pcie_buscore_write32,
}; };
static void brcmf_pcie_setup(struct device *dev, const struct firmware *fw, static void brcmf_pcie_setup(struct device *dev, int ret,
const struct firmware *fw,
void *nvram, u32 nvram_len) void *nvram, u32 nvram_len)
{ {
struct brcmf_bus *bus = dev_get_drvdata(dev); struct brcmf_bus *bus;
struct brcmf_pciedev *pcie_bus_dev = bus->bus_priv.pcie; struct brcmf_pciedev *pcie_bus_dev;
struct brcmf_pciedev_info *devinfo = pcie_bus_dev->devinfo; struct brcmf_pciedev_info *devinfo;
struct brcmf_commonring **flowrings; struct brcmf_commonring **flowrings;
int ret;
u32 i; u32 i;
/* check firmware loading result */
if (ret)
goto fail;
bus = dev_get_drvdata(dev);
pcie_bus_dev = bus->bus_priv.pcie;
devinfo = pcie_bus_dev->devinfo;
brcmf_pcie_attach(devinfo); brcmf_pcie_attach(devinfo);
/* Some of the firmwares have the size of the memory of the device /* Some of the firmwares have the size of the memory of the device
......
...@@ -3982,21 +3982,26 @@ static const struct brcmf_bus_ops brcmf_sdio_bus_ops = { ...@@ -3982,21 +3982,26 @@ static const struct brcmf_bus_ops brcmf_sdio_bus_ops = {
.get_memdump = brcmf_sdio_bus_get_memdump, .get_memdump = brcmf_sdio_bus_get_memdump,
}; };
static void brcmf_sdio_firmware_callback(struct device *dev, static void brcmf_sdio_firmware_callback(struct device *dev, int err,
const struct firmware *code, const struct firmware *code,
void *nvram, u32 nvram_len) void *nvram, u32 nvram_len)
{ {
struct brcmf_bus *bus_if = dev_get_drvdata(dev); struct brcmf_bus *bus_if;
struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; struct brcmf_sdio_dev *sdiodev;
struct brcmf_sdio *bus = sdiodev->bus; struct brcmf_sdio *bus;
int err = 0;
u8 saveclk; u8 saveclk;
brcmf_dbg(TRACE, "Enter: dev=%s\n", dev_name(dev)); brcmf_dbg(TRACE, "Enter: dev=%s, err=%d\n", dev_name(dev), err);
if (err)
goto fail;
bus_if = dev_get_drvdata(dev);
if (!bus_if->drvr) if (!bus_if->drvr)
return; return;
sdiodev = bus_if->bus_priv.sdio;
bus = sdiodev->bus;
/* try to download image and nvram to the dongle */ /* try to download image and nvram to the dongle */
bus->alp_only = true; bus->alp_only = true;
err = brcmf_sdio_download_firmware(bus, code, nvram, nvram_len); err = brcmf_sdio_download_firmware(bus, code, nvram, nvram_len);
......
...@@ -1159,13 +1159,15 @@ static int brcmf_usb_bus_setup(struct brcmf_usbdev_info *devinfo) ...@@ -1159,13 +1159,15 @@ static int brcmf_usb_bus_setup(struct brcmf_usbdev_info *devinfo)
return ret; return ret;
} }
static void brcmf_usb_probe_phase2(struct device *dev, static void brcmf_usb_probe_phase2(struct device *dev, int ret,
const struct firmware *fw, const struct firmware *fw,
void *nvram, u32 nvlen) void *nvram, u32 nvlen)
{ {
struct brcmf_bus *bus = dev_get_drvdata(dev); struct brcmf_bus *bus = dev_get_drvdata(dev);
struct brcmf_usbdev_info *devinfo; struct brcmf_usbdev_info *devinfo;
int ret;
if (ret)
goto error;
brcmf_dbg(USB, "Start fw downloading\n"); brcmf_dbg(USB, "Start fw downloading\n");
......
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