Commit 47b4c640 authored by Franky Lin's avatar Franky Lin Committed by Greg Kroah-Hartman

staging: brcm80211: remove global var gInstance from brcmfmac

Use sdio function pointer stored in struct brcmf_sdio_dev instead
of those in gInstance.
Reviewed-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent b73b2f9e
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include <linux/pci_ids.h> #include <linux/pci_ids.h>
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/mmc/card.h>
#include <defs.h> #include <defs.h>
#include <brcm_hw_ids.h> #include <brcm_hw_ids.h>
...@@ -55,12 +56,12 @@ brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name, ...@@ -55,12 +56,12 @@ brcmf_sdcard_iovar_op(struct brcmf_sdio_dev *sdiodev, const char *name,
int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev) int brcmf_sdcard_intr_reg(struct brcmf_sdio_dev *sdiodev)
{ {
return brcmf_sdioh_interrupt_register(); return brcmf_sdioh_interrupt_register(sdiodev);
} }
int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev) int brcmf_sdcard_intr_dereg(struct brcmf_sdio_dev *sdiodev)
{ {
return brcmf_sdioh_interrupt_deregister(); return brcmf_sdioh_interrupt_deregister(sdiodev);
} }
u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr, u8 brcmf_sdcard_cfg_read(struct brcmf_sdio_dev *sdiodev, uint fnc_num, u32 addr,
......
...@@ -58,8 +58,6 @@ static int brcmf_sdio_resume(struct device *dev); ...@@ -58,8 +58,6 @@ static int brcmf_sdio_resume(struct device *dev);
uint sd_f2_blocksize = 512; /* Default blocksize */ uint sd_f2_blocksize = 512; /* Default blocksize */
struct brcmf_sdmmc_instance *gInstance;
/* devices we support, null terminated */ /* devices we support, null terminated */
static const struct sdio_device_id brcmf_sdmmc_ids[] = { static const struct sdio_device_id brcmf_sdmmc_ids[] = {
{SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)}, {SDIO_DEVICE(SDIO_VENDOR_ID_BROADCOM, SDIO_DEVICE_ID_BROADCOM_4329)},
...@@ -133,9 +131,9 @@ static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev) ...@@ -133,9 +131,9 @@ static int brcmf_sdioh_enablefuncs(struct brcmf_sdio_dev *sdiodev)
} }
/* Enable Function 1 */ /* Enable Function 1 */
sdio_claim_host(gInstance->func[1]); sdio_claim_host(sdiodev->func[1]);
err_ret = sdio_enable_func(gInstance->func[1]); err_ret = sdio_enable_func(sdiodev->func[1]);
sdio_release_host(gInstance->func[1]); sdio_release_host(sdiodev->func[1]);
if (err_ret) if (err_ret)
BRCMF_ERROR(("brcmf_sdioh_enablefuncs: Failed to enable F1 " BRCMF_ERROR(("brcmf_sdioh_enablefuncs: Failed to enable F1 "
"Err: 0x%08x\n", err_ret)); "Err: 0x%08x\n", err_ret));
...@@ -152,32 +150,23 @@ int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev) ...@@ -152,32 +150,23 @@ int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev)
BRCMF_TRACE(("%s\n", __func__)); BRCMF_TRACE(("%s\n", __func__));
if (gInstance == NULL) {
BRCMF_ERROR(("%s: SDIO Device not present\n", __func__));
err_ret = -ENODEV;
goto out;
}
sdiodev->num_funcs = 2; sdiodev->num_funcs = 2;
sdio_claim_host(gInstance->func[1]); sdio_claim_host(sdiodev->func[1]);
err_ret = sdio_set_block_size(gInstance->func[1], 64); err_ret = sdio_set_block_size(sdiodev->func[1], 64);
sdio_release_host(gInstance->func[1]); sdio_release_host(sdiodev->func[1]);
if (err_ret) { if (err_ret) {
BRCMF_ERROR(("%s: Failed to set F1 blocksize\n", __func__)); BRCMF_ERROR(("%s: Failed to set F1 blocksize\n", __func__));
goto out; goto out;
} }
if (gInstance->func[2]) { sdio_claim_host(sdiodev->func[2]);
sdio_claim_host(gInstance->func[2]); err_ret = sdio_set_block_size(sdiodev->func[2], sd_f2_blocksize);
err_ret = sdio_release_host(sdiodev->func[2]);
sdio_set_block_size(gInstance->func[2], sd_f2_blocksize); if (err_ret) {
sdio_release_host(gInstance->func[2]); BRCMF_ERROR(("%s: Failed to set F2 blocksize"
if (err_ret) { " to %d\n", __func__, sd_f2_blocksize));
BRCMF_ERROR(("%s: Failed to set F2 blocksize" goto out;
" to %d\n", __func__, sd_f2_blocksize));
goto out;
}
} }
brcmf_sdioh_enablefuncs(sdiodev); brcmf_sdioh_enablefuncs(sdiodev);
...@@ -192,56 +181,56 @@ void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev) ...@@ -192,56 +181,56 @@ void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev)
BRCMF_TRACE(("%s\n", __func__)); BRCMF_TRACE(("%s\n", __func__));
/* Disable Function 2 */ /* Disable Function 2 */
sdio_claim_host(gInstance->func[2]); sdio_claim_host(sdiodev->func[2]);
sdio_disable_func(gInstance->func[2]); sdio_disable_func(sdiodev->func[2]);
sdio_release_host(gInstance->func[2]); sdio_release_host(sdiodev->func[2]);
/* Disable Function 1 */ /* Disable Function 1 */
sdio_claim_host(gInstance->func[1]); sdio_claim_host(sdiodev->func[1]);
sdio_disable_func(gInstance->func[1]); sdio_disable_func(sdiodev->func[1]);
sdio_release_host(gInstance->func[1]); sdio_release_host(sdiodev->func[1]);
} }
/* Configure callback to client when we receive client interrupt */ /* Configure callback to client when we receive client interrupt */
extern int extern int
brcmf_sdioh_interrupt_register(void) brcmf_sdioh_interrupt_register(struct brcmf_sdio_dev *sdiodev)
{ {
BRCMF_TRACE(("%s: Entering\n", __func__)); BRCMF_TRACE(("%s: Entering\n", __func__));
/* register and unmask irq */ /* register and unmask irq */
if (gInstance->func[2]) { if (sdiodev->func[2]) {
sdio_claim_host(gInstance->func[2]); sdio_claim_host(sdiodev->func[2]);
sdio_claim_irq(gInstance->func[2], brcmf_sdioh_irqhandler_f2); sdio_claim_irq(sdiodev->func[2], brcmf_sdioh_irqhandler_f2);
sdio_release_host(gInstance->func[2]); sdio_release_host(sdiodev->func[2]);
} }
if (gInstance->func[1]) { if (sdiodev->func[1]) {
sdio_claim_host(gInstance->func[1]); sdio_claim_host(sdiodev->func[1]);
sdio_claim_irq(gInstance->func[1], brcmf_sdioh_irqhandler); sdio_claim_irq(sdiodev->func[1], brcmf_sdioh_irqhandler);
sdio_release_host(gInstance->func[1]); sdio_release_host(sdiodev->func[1]);
} }
return 0; return 0;
} }
extern int brcmf_sdioh_interrupt_deregister(void) int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev)
{ {
BRCMF_TRACE(("%s: Entering\n", __func__)); BRCMF_TRACE(("%s: Entering\n", __func__));
if (gInstance->func[1]) { if (sdiodev->func[1]) {
/* register and unmask irq */ /* register and unmask irq */
sdio_claim_host(gInstance->func[1]); sdio_claim_host(sdiodev->func[1]);
sdio_release_irq(gInstance->func[1]); sdio_release_irq(sdiodev->func[1]);
sdio_release_host(gInstance->func[1]); sdio_release_host(sdiodev->func[1]);
} }
if (gInstance->func[2]) { if (sdiodev->func[2]) {
/* Claim host controller F2 */ /* Claim host controller F2 */
sdio_claim_host(gInstance->func[2]); sdio_claim_host(sdiodev->func[2]);
sdio_release_irq(gInstance->func[2]); sdio_release_irq(sdiodev->func[2]);
/* Release host controller F2 */ /* Release host controller F2 */
sdio_release_host(gInstance->func[2]); sdio_release_host(sdiodev->func[2]);
} }
return 0; return 0;
...@@ -450,8 +439,8 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, ...@@ -450,8 +439,8 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func,
BRCMF_INFO(("%s: rw=%d, func=%d, addr=0x%05x\n", __func__, rw, func, BRCMF_INFO(("%s: rw=%d, func=%d, addr=0x%05x\n", __func__, rw, func,
regaddr)); regaddr));
BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, gInstance); BRCMF_PM_RESUME_WAIT(sdioh_request_byte_wait, sdiodev);
BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev);
if (rw) { /* CMD52 Write */ if (rw) { /* CMD52 Write */
if (func == 0) { if (func == 0) {
/* Can only directly write to some F0 registers. /* Can only directly write to some F0 registers.
...@@ -459,13 +448,13 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, ...@@ -459,13 +448,13 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func,
* as a special case. * as a special case.
*/ */
if (regaddr == SDIO_CCCR_IOEx) { if (regaddr == SDIO_CCCR_IOEx) {
if (gInstance->func[2]) { if (sdiodev->func[2]) {
sdio_claim_host(gInstance->func[2]); sdio_claim_host(sdiodev->func[2]);
if (*byte & SDIO_FUNC_ENABLE_2) { if (*byte & SDIO_FUNC_ENABLE_2) {
/* Enable Function 2 */ /* Enable Function 2 */
err_ret = err_ret =
sdio_enable_func sdio_enable_func
(gInstance->func[2]); (sdiodev->func[2]);
if (err_ret) if (err_ret)
BRCMF_ERROR(( BRCMF_ERROR((
"request_byte: " "request_byte: "
...@@ -476,7 +465,7 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, ...@@ -476,7 +465,7 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func,
/* Disable Function 2 */ /* Disable Function 2 */
err_ret = err_ret =
sdio_disable_func sdio_disable_func
(gInstance->func[2]); (sdiodev->func[2]);
if (err_ret) if (err_ret)
BRCMF_ERROR(( BRCMF_ERROR((
"request_byte: " "request_byte: "
...@@ -484,55 +473,55 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func, ...@@ -484,55 +473,55 @@ brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, uint func,
"failed:%d\n", "failed:%d\n",
err_ret)); err_ret));
} }
sdio_release_host(gInstance->func[2]); sdio_release_host(sdiodev->func[2]);
} }
} }
/* to allow abort command through F1 */ /* to allow abort command through F1 */
else if (regaddr == SDIO_CCCR_ABORT) { else if (regaddr == SDIO_CCCR_ABORT) {
sdio_claim_host(gInstance->func[func]); sdio_claim_host(sdiodev->func[func]);
/* /*
* this sdio_f0_writeb() can be replaced * this sdio_f0_writeb() can be replaced
* with another api * with another api
* depending upon MMC driver change. * depending upon MMC driver change.
* As of this time, this is temporaray one * As of this time, this is temporaray one
*/ */
sdio_writeb(gInstance->func[func], *byte, sdio_writeb(sdiodev->func[func], *byte,
regaddr, &err_ret); regaddr, &err_ret);
sdio_release_host(gInstance->func[func]); sdio_release_host(sdiodev->func[func]);
} else if (regaddr < 0xF0) { } else if (regaddr < 0xF0) {
BRCMF_ERROR(("brcmf: F0 Wr:0x%02x: write " BRCMF_ERROR(("brcmf: F0 Wr:0x%02x: write "
"disallowed\n", regaddr)); "disallowed\n", regaddr));
} else { } else {
/* Claim host controller, perform F0 write, /* Claim host controller, perform F0 write,
and release */ and release */
sdio_claim_host(gInstance->func[func]); sdio_claim_host(sdiodev->func[func]);
sdio_f0_writeb(gInstance->func[func], *byte, sdio_f0_writeb(sdiodev->func[func], *byte,
regaddr, &err_ret); regaddr, &err_ret);
sdio_release_host(gInstance->func[func]); sdio_release_host(sdiodev->func[func]);
} }
} else { } else {
/* Claim host controller, perform Fn write, /* Claim host controller, perform Fn write,
and release */ and release */
sdio_claim_host(gInstance->func[func]); sdio_claim_host(sdiodev->func[func]);
sdio_writeb(gInstance->func[func], *byte, regaddr, sdio_writeb(sdiodev->func[func], *byte, regaddr,
&err_ret); &err_ret);
sdio_release_host(gInstance->func[func]); sdio_release_host(sdiodev->func[func]);
} }
} else { /* CMD52 Read */ } else { /* CMD52 Read */
/* Claim host controller, perform Fn read, and release */ /* Claim host controller, perform Fn read, and release */
sdio_claim_host(gInstance->func[func]); sdio_claim_host(sdiodev->func[func]);
if (func == 0) { if (func == 0) {
*byte = *byte =
sdio_f0_readb(gInstance->func[func], regaddr, sdio_f0_readb(sdiodev->func[func], regaddr,
&err_ret); &err_ret);
} else { } else {
*byte = *byte =
sdio_readb(gInstance->func[func], regaddr, sdio_readb(sdiodev->func[func], regaddr,
&err_ret); &err_ret);
} }
sdio_release_host(gInstance->func[func]); sdio_release_host(sdiodev->func[func]);
} }
if (err_ret) if (err_ret)
...@@ -557,17 +546,17 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, ...@@ -557,17 +546,17 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw,
BRCMF_INFO(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n", BRCMF_INFO(("%s: cmd_type=%d, rw=%d, func=%d, addr=0x%05x, nbytes=%d\n",
__func__, cmd_type, rw, func, addr, nbytes)); __func__, cmd_type, rw, func, addr, nbytes));
BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, gInstance); BRCMF_PM_RESUME_WAIT(sdioh_request_word_wait, sdiodev);
BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev);
/* Claim host controller */ /* Claim host controller */
sdio_claim_host(gInstance->func[func]); sdio_claim_host(sdiodev->func[func]);
if (rw) { /* CMD52 Write */ if (rw) { /* CMD52 Write */
if (nbytes == 4) if (nbytes == 4)
sdio_writel(gInstance->func[func], *word, addr, sdio_writel(sdiodev->func[func], *word, addr,
&err_ret); &err_ret);
else if (nbytes == 2) else if (nbytes == 2)
sdio_writew(gInstance->func[func], (*word & 0xFFFF), sdio_writew(sdiodev->func[func], (*word & 0xFFFF),
addr, &err_ret); addr, &err_ret);
else else
BRCMF_ERROR(("%s: Invalid nbytes: %d\n", BRCMF_ERROR(("%s: Invalid nbytes: %d\n",
...@@ -575,10 +564,10 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, ...@@ -575,10 +564,10 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw,
} else { /* CMD52 Read */ } else { /* CMD52 Read */
if (nbytes == 4) if (nbytes == 4)
*word = *word =
sdio_readl(gInstance->func[func], addr, &err_ret); sdio_readl(sdiodev->func[func], addr, &err_ret);
else if (nbytes == 2) else if (nbytes == 2)
*word = *word =
sdio_readw(gInstance->func[func], addr, sdio_readw(sdiodev->func[func], addr,
&err_ret) & 0xFFFF; &err_ret) & 0xFFFF;
else else
BRCMF_ERROR(("%s: Invalid nbytes: %d\n", BRCMF_ERROR(("%s: Invalid nbytes: %d\n",
...@@ -586,7 +575,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw, ...@@ -586,7 +575,7 @@ brcmf_sdioh_request_word(struct brcmf_sdio_dev *sdiodev, uint cmd_type, uint rw,
} }
/* Release host controller */ /* Release host controller */
sdio_release_host(gInstance->func[func]); sdio_release_host(sdiodev->func[func]);
if (err_ret) if (err_ret)
BRCMF_ERROR(("brcmf: Failed to %s word, Err: 0x%08x\n", BRCMF_ERROR(("brcmf: Failed to %s word, Err: 0x%08x\n",
...@@ -608,30 +597,30 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, ...@@ -608,30 +597,30 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc,
BRCMF_TRACE(("%s: Enter\n", __func__)); BRCMF_TRACE(("%s: Enter\n", __func__));
BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, gInstance); BRCMF_PM_RESUME_WAIT(sdioh_request_packet_wait, sdiodev);
BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev);
/* Claim host controller */ /* Claim host controller */
sdio_claim_host(gInstance->func[func]); sdio_claim_host(sdiodev->func[func]);
for (pnext = pkt; pnext; pnext = pnext->next) { for (pnext = pkt; pnext; pnext = pnext->next) {
uint pkt_len = pnext->len; uint pkt_len = pnext->len;
pkt_len += 3; pkt_len += 3;
pkt_len &= 0xFFFFFFFC; pkt_len &= 0xFFFFFFFC;
if ((write) && (!fifo)) { if ((write) && (!fifo)) {
err_ret = sdio_memcpy_toio(gInstance->func[func], addr, err_ret = sdio_memcpy_toio(sdiodev->func[func], addr,
((u8 *) (pnext->data)), ((u8 *) (pnext->data)),
pkt_len); pkt_len);
} else if (write) { } else if (write) {
err_ret = sdio_memcpy_toio(gInstance->func[func], addr, err_ret = sdio_memcpy_toio(sdiodev->func[func], addr,
((u8 *) (pnext->data)), ((u8 *) (pnext->data)),
pkt_len); pkt_len);
} else if (fifo) { } else if (fifo) {
err_ret = sdio_readsb(gInstance->func[func], err_ret = sdio_readsb(sdiodev->func[func],
((u8 *) (pnext->data)), ((u8 *) (pnext->data)),
addr, pkt_len); addr, pkt_len);
} else { } else {
err_ret = sdio_memcpy_fromio(gInstance->func[func], err_ret = sdio_memcpy_fromio(sdiodev->func[func],
((u8 *) (pnext->data)), ((u8 *) (pnext->data)),
addr, pkt_len); addr, pkt_len);
} }
...@@ -655,7 +644,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc, ...@@ -655,7 +644,7 @@ brcmf_sdioh_request_packet(struct brcmf_sdio_dev *sdiodev, uint fix_inc,
} }
/* Release host controller */ /* Release host controller */
sdio_release_host(gInstance->func[func]); sdio_release_host(sdiodev->func[func]);
BRCMF_TRACE(("%s: Exit\n", __func__)); BRCMF_TRACE(("%s: Exit\n", __func__));
return err_ret; return err_ret;
...@@ -687,8 +676,8 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma, ...@@ -687,8 +676,8 @@ brcmf_sdioh_request_buffer(struct brcmf_sdio_dev *sdiodev, uint pio_dma,
BRCMF_TRACE(("%s: Enter\n", __func__)); BRCMF_TRACE(("%s: Enter\n", __func__));
BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, gInstance); BRCMF_PM_RESUME_WAIT(sdioh_request_buffer_wait, sdiodev);
BRCMF_PM_RESUME_RETURN_ERROR(-EIO, gInstance); BRCMF_PM_RESUME_RETURN_ERROR(-EIO, sdiodev);
/* Case 1: we don't have a packet. */ /* Case 1: we don't have a packet. */
if (pkt == NULL) { if (pkt == NULL) {
BRCMF_DATA(("%s: Creating new %s Packet, len=%d\n", BRCMF_DATA(("%s: Creating new %s Packet, len=%d\n",
...@@ -795,11 +784,11 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func) ...@@ -795,11 +784,11 @@ static void brcmf_sdioh_irqhandler(struct sdio_func *func)
BRCMF_TRACE(("brcmf: ***IRQHandler\n")); BRCMF_TRACE(("brcmf: ***IRQHandler\n"));
sdio_release_host(gInstance->func[0]); sdio_release_host(func);
brcmf_sdbrcm_isr(sdiodev->bus); brcmf_sdbrcm_isr(sdiodev->bus);
sdio_claim_host(gInstance->func[0]); sdio_claim_host(func);
} }
/* interrupt handler for F2 (dummy handler) */ /* interrupt handler for F2 (dummy handler) */
...@@ -812,7 +801,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -812,7 +801,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
const struct sdio_device_id *id) const struct sdio_device_id *id)
{ {
int ret = 0; int ret = 0;
static struct sdio_func sdio_func_0;
struct brcmf_sdio_dev *sdiodev; struct brcmf_sdio_dev *sdiodev;
BRCMF_TRACE(("sdio_probe: %s Enter\n", __func__)); BRCMF_TRACE(("sdio_probe: %s Enter\n", __func__));
BRCMF_TRACE(("sdio_probe: func->class=%x\n", func->class)); BRCMF_TRACE(("sdio_probe: func->class=%x\n", func->class));
...@@ -821,10 +809,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -821,10 +809,6 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
BRCMF_TRACE(("Function#: 0x%04x\n", func->num)); BRCMF_TRACE(("Function#: 0x%04x\n", func->num));
if (func->num == 1) { if (func->num == 1) {
sdio_func_0.num = 0;
sdio_func_0.card = func->card;
gInstance->func[0] = &sdio_func_0;
if (dev_get_drvdata(&func->card->dev)) { if (dev_get_drvdata(&func->card->dev)) {
BRCMF_ERROR(("%s: card private drvdata occupied.\n", BRCMF_ERROR(("%s: card private drvdata occupied.\n",
__func__)); __func__));
...@@ -833,19 +817,18 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -833,19 +817,18 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL); sdiodev = kzalloc(sizeof(struct brcmf_sdio_dev), GFP_KERNEL);
if (!sdiodev) if (!sdiodev)
return -ENOMEM; return -ENOMEM;
sdiodev->func1 = func; sdiodev->func[0] = func->card->sdio_func[0];
sdiodev->func[1] = func;
dev_set_drvdata(&func->card->dev, sdiodev); dev_set_drvdata(&func->card->dev, sdiodev);
atomic_set(&gInstance->suspend, false); atomic_set(&sdiodev->suspend, false);
} }
gInstance->func[func->num] = func;
if (func->num == 2) { if (func->num == 2) {
sdiodev = dev_get_drvdata(&func->card->dev); sdiodev = dev_get_drvdata(&func->card->dev);
if ((!sdiodev) || (sdiodev->func1->card != func->card)) if ((!sdiodev) || (sdiodev->func[1]->card != func->card))
return -ENODEV; return -ENODEV;
sdiodev->func2 = func; sdiodev->func[2] = func;
brcmf_cfg80211_sdio_func(func); brcmf_cfg80211_sdio_func(func);
BRCMF_TRACE(("F2 found, calling brcmf_sdio_probe...\n")); BRCMF_TRACE(("F2 found, calling brcmf_sdio_probe...\n"));
...@@ -884,21 +867,22 @@ static int brcmf_sdio_suspend(struct device *dev) ...@@ -884,21 +867,22 @@ static int brcmf_sdio_suspend(struct device *dev)
BRCMF_TRACE(("%s\n", __func__)); BRCMF_TRACE(("%s\n", __func__));
atomic_set(&gInstance->suspend, true); sdiodev = dev_get_drvdata(&func->card->dev);
atomic_set(&sdiodev->suspend, true);
sdio_flags = sdio_get_host_pm_caps(gInstance->func[1]); sdio_flags = sdio_get_host_pm_caps(sdiodev->func[1]);
if (!(sdio_flags & MMC_PM_KEEP_POWER)) { if (!(sdio_flags & MMC_PM_KEEP_POWER)) {
BRCMF_ERROR(("Host can't keep power while suspended\n")); BRCMF_ERROR(("Host can't keep power while suspended\n"));
return -EINVAL; return -EINVAL;
} }
ret = sdio_set_host_pm_flags(gInstance->func[1], MMC_PM_KEEP_POWER); ret = sdio_set_host_pm_flags(sdiodev->func[1], MMC_PM_KEEP_POWER);
if (ret) { if (ret) {
BRCMF_ERROR(("Failed to set pm_flags\n")); BRCMF_ERROR(("Failed to set pm_flags\n"));
return ret; return ret;
} }
sdiodev = dev_get_drvdata(&func->card->dev);
brcmf_sdio_wdtmr_enable(sdiodev, false); brcmf_sdio_wdtmr_enable(sdiodev, false);
return ret; return ret;
...@@ -911,7 +895,7 @@ static int brcmf_sdio_resume(struct device *dev) ...@@ -911,7 +895,7 @@ static int brcmf_sdio_resume(struct device *dev)
sdiodev = dev_get_drvdata(&func->card->dev); sdiodev = dev_get_drvdata(&func->card->dev);
brcmf_sdio_wdtmr_enable(sdiodev, true); brcmf_sdio_wdtmr_enable(sdiodev, true);
atomic_set(&gInstance->suspend, false); atomic_set(&sdiodev->suspend, false);
return 0; return 0;
} }
#endif /* CONFIG_PM_SLEEP */ #endif /* CONFIG_PM_SLEEP */
...@@ -924,10 +908,6 @@ int brcmf_sdio_function_init(void) ...@@ -924,10 +908,6 @@ int brcmf_sdio_function_init(void)
int error = 0; int error = 0;
BRCMF_TRACE(("brcmf_sdio_function_init: %s Enter\n", __func__)); BRCMF_TRACE(("brcmf_sdio_function_init: %s Enter\n", __func__));
gInstance = kzalloc(sizeof(struct brcmf_sdmmc_instance), GFP_KERNEL);
if (!gInstance)
return -ENOMEM;
error = sdio_register_driver(&brcmf_sdmmc_driver); error = sdio_register_driver(&brcmf_sdmmc_driver);
return error; return error;
...@@ -941,6 +921,4 @@ void brcmf_sdio_function_cleanup(void) ...@@ -941,6 +921,4 @@ void brcmf_sdio_function_cleanup(void)
BRCMF_TRACE(("%s Enter\n", __func__)); BRCMF_TRACE(("%s Enter\n", __func__));
sdio_unregister_driver(&brcmf_sdmmc_driver); sdio_unregister_driver(&brcmf_sdmmc_driver);
kfree(gInstance);
} }
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <linux/sched.h> #include <linux/sched.h>
#include <linux/mmc/sdio.h> #include <linux/mmc/sdio.h>
#include <linux/mmc/sdio_func.h> #include <linux/mmc/sdio_func.h>
#include <linux/mmc/card.h>
#include <linux/semaphore.h> #include <linux/semaphore.h>
#include <linux/firmware.h> #include <linux/firmware.h>
#include <asm/unaligned.h> #include <asm/unaligned.h>
...@@ -5685,7 +5686,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus) ...@@ -5685,7 +5686,7 @@ static bool brcmf_sdbrcm_probe_init(struct brcmf_bus *bus)
bus->idleclock = BRCMF_IDLE_ACTIVE; bus->idleclock = BRCMF_IDLE_ACTIVE;
/* Query the F2 block size, set roundup accordingly */ /* Query the F2 block size, set roundup accordingly */
bus->blocksize = bus->sdiodev->func2->cur_blksize; bus->blocksize = bus->sdiodev->func[2]->cur_blksize;
bus->roundup = min(max_roundup, bus->blocksize); bus->roundup = min(max_roundup, bus->blocksize);
/* Query if bus module supports packet chaining, /* Query if bus module supports packet chaining,
...@@ -5828,7 +5829,7 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus) ...@@ -5828,7 +5829,7 @@ static int brcmf_sdbrcm_download_code_file(struct brcmf_bus *bus)
bus->fw_name = BCM4329_FW_NAME; bus->fw_name = BCM4329_FW_NAME;
ret = request_firmware(&bus->firmware, bus->fw_name, ret = request_firmware(&bus->firmware, bus->fw_name,
&gInstance->func[2]->dev); &bus->sdiodev->func[2]->dev);
if (ret) { if (ret) {
BRCMF_ERROR(("%s: Fail to request firmware %d\n", BRCMF_ERROR(("%s: Fail to request firmware %d\n",
__func__, ret)); __func__, ret));
...@@ -5930,7 +5931,7 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus) ...@@ -5930,7 +5931,7 @@ static int brcmf_sdbrcm_download_nvram(struct brcmf_bus *bus)
bus->nv_name = BCM4329_NV_NAME; bus->nv_name = BCM4329_NV_NAME;
ret = request_firmware(&bus->firmware, bus->nv_name, ret = request_firmware(&bus->firmware, bus->nv_name,
&gInstance->func[2]->dev); &bus->sdiodev->func[2]->dev);
if (ret) { if (ret) {
BRCMF_ERROR(("%s: Fail to request nvram %d\n", __func__, ret)); BRCMF_ERROR(("%s: Fail to request nvram %d\n", __func__, ret));
return ret; return ret;
......
...@@ -122,20 +122,14 @@ struct brcmf_sdreg { ...@@ -122,20 +122,14 @@ struct brcmf_sdreg {
int value; int value;
}; };
struct brcmf_sdmmc_instance {
struct sdio_func *func[SDIOD_MAX_IOFUNCS];
u32 host_claimed;
atomic_t suspend; /* suspend flag */
};
struct brcmf_sdio_dev { struct brcmf_sdio_dev {
struct sdio_func *func1; struct sdio_func *func[SDIO_MAX_FUNCS];
struct sdio_func *func2;
u8 num_funcs; /* Supported funcs on client */ u8 num_funcs; /* Supported funcs on client */
u32 func_cis_ptr[SDIOD_MAX_IOFUNCS]; u32 func_cis_ptr[SDIOD_MAX_IOFUNCS];
u32 sbwad; /* Save backplane window address */ u32 sbwad; /* Save backplane window address */
bool regfail; /* status of last reg_r/w call */ bool regfail; /* status of last reg_r/w call */
void *bus; void *bus;
atomic_t suspend; /* suspend flag */
}; };
/* Register/deregister device interrupt handler. */ /* Register/deregister device interrupt handler. */
...@@ -253,10 +247,8 @@ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev); ...@@ -253,10 +247,8 @@ extern u32 brcmf_sdcard_cur_sbwad(struct brcmf_sdio_dev *sdiodev);
extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev); extern int brcmf_sdioh_attach(struct brcmf_sdio_dev *sdiodev);
extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev); extern void brcmf_sdioh_detach(struct brcmf_sdio_dev *sdiodev);
extern int extern int brcmf_sdioh_interrupt_register(struct brcmf_sdio_dev *sdiodev);
brcmf_sdioh_interrupt_register(void); extern int brcmf_sdioh_interrupt_deregister(struct brcmf_sdio_dev *sdiodev);
extern int brcmf_sdioh_interrupt_deregister(void);
/* read or write one byte using cmd52 */ /* read or write one byte using cmd52 */
extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw, extern int brcmf_sdioh_request_byte(struct brcmf_sdio_dev *sdiodev, uint rw,
...@@ -298,8 +290,6 @@ extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev, ...@@ -298,8 +290,6 @@ extern void brcmf_sdio_wdtmr_enable(struct brcmf_sdio_dev *sdiodev,
extern uint sd_f2_blocksize; extern uint sd_f2_blocksize;
extern struct brcmf_sdmmc_instance *gInstance;
extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype, extern void *brcmf_sdbrcm_probe(u16 bus_no, u16 slot, u16 func, uint bustype,
u32 regsva, struct brcmf_sdio_dev *sdiodev); u32 regsva, struct brcmf_sdio_dev *sdiodev);
extern void brcmf_sdbrcm_disconnect(void *ptr); extern void brcmf_sdbrcm_disconnect(void *ptr);
......
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