Commit 36c4e7e4 authored by Arend van Spriel's avatar Arend van Spriel Committed by John W. Linville

brcmfmac: clarify struct brcmf_sdio_dev::func[0] reference

The struct brcmf_sdio_dev contains array of sdio functions that
are used in the driver. However, during probe func[0] entry was
assigned to the function 1 reference. This was corrected upon
doing the actual I/O access. This patch makes it more clear by
creating the func[0] entry properly and use it as is during
I/O access.
Reviewed-by: default avatarFranky Lin <frankyl@broadcom.com>
Reviewed-by: default avatarHante Meuleman <meuleman@broadcom.com>
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent 9fbe2a6d
...@@ -197,32 +197,21 @@ int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev) ...@@ -197,32 +197,21 @@ int brcmf_sdiod_intr_unregister(struct brcmf_sdio_dev *sdiodev)
return 0; return 0;
} }
static inline int brcmf_sdiod_f0_write_byte(struct brcmf_sdio_dev *sdiodev, static inline int brcmf_sdiod_f0_writeb(struct sdio_func *func,
uint regaddr, u8 *byte) uint regaddr, u8 byte)
{ {
struct sdio_func *sdfunc = sdiodev->func[0];
int err_ret; int err_ret;
/* /*
* Can only directly write to some F0 registers. * Can only directly write to some F0 registers.
* Handle F2 enable/disable and Abort command * Handle CCCR_IENx and CCCR_ABORT command
* as a special case. * as a special case.
*/ */
if ((regaddr == SDIO_CCCR_ABORT) || if ((regaddr == SDIO_CCCR_ABORT) ||
(regaddr == SDIO_CCCR_IENx)) { (regaddr == SDIO_CCCR_IENx))
sdfunc = kmemdup(sdiodev->func[0], sizeof(struct sdio_func), sdio_writeb(func, byte, regaddr, &err_ret);
GFP_KERNEL); else
if (!sdfunc) sdio_f0_writeb(func, byte, regaddr, &err_ret);
return -ENOMEM;
sdfunc->num = 0;
sdio_writeb(sdfunc, *byte, regaddr, &err_ret);
kfree(sdfunc);
} else if (regaddr < 0xF0) {
brcmf_err("F0 Wr:0x%02x: write disallowed\n", regaddr);
err_ret = -EPERM;
} else {
sdio_f0_writeb(sdfunc, *byte, regaddr, &err_ret);
}
return err_ret; return err_ret;
} }
...@@ -240,7 +229,8 @@ static int brcmf_sdiod_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, ...@@ -240,7 +229,8 @@ static int brcmf_sdiod_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw,
if (rw && func == 0) { if (rw && func == 0) {
/* handle F0 separately */ /* handle F0 separately */
err_ret = brcmf_sdiod_f0_write_byte(sdiodev, regaddr, byte); err_ret = brcmf_sdiod_f0_writeb(sdiodev->func[func],
regaddr, *byte);
} else { } else {
if (rw) /* CMD52 Write */ if (rw) /* CMD52 Write */
sdio_writeb(sdiodev->func[func], *byte, regaddr, sdio_writeb(sdiodev->func[func], *byte, regaddr,
...@@ -1030,7 +1020,11 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -1030,7 +1020,11 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
return -ENOMEM; return -ENOMEM;
} }
sdiodev->func[0] = func->card->sdio_func[0]; /* store refs to functions used. mmc_card does
* not hold the F0 function pointer.
*/
sdiodev->func[0] = kmemdup(func, sizeof(*func), GFP_KERNEL);
sdiodev->func[0]->num = 0;
sdiodev->func[1] = func->card->sdio_func[0]; sdiodev->func[1] = func->card->sdio_func[0];
sdiodev->func[2] = func; sdiodev->func[2] = func;
...@@ -1060,6 +1054,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -1060,6 +1054,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
fail: fail:
dev_set_drvdata(&func->dev, NULL); dev_set_drvdata(&func->dev, NULL);
dev_set_drvdata(&sdiodev->func[1]->dev, NULL); dev_set_drvdata(&sdiodev->func[1]->dev, NULL);
kfree(sdiodev->func[0]);
kfree(sdiodev); kfree(sdiodev);
kfree(bus_if); kfree(bus_if);
return err; return err;
...@@ -1087,6 +1082,7 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) ...@@ -1087,6 +1082,7 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func)
dev_set_drvdata(&sdiodev->func[2]->dev, NULL); dev_set_drvdata(&sdiodev->func[2]->dev, NULL);
kfree(bus_if); kfree(bus_if);
kfree(sdiodev->func[0]);
kfree(sdiodev); kfree(sdiodev);
} }
......
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