Commit 655713be authored by Franky Lin's avatar Franky Lin Committed by John W. Linville

brcm80211: fmac: introduce common bus interface struct brcmf_bus

struct brcmf_bus will contain function porinter, bus specific
private structure pointer and interface context of generic layer
and bus layer. It will be the only shared structure between generic
and bus layer. This patch is part of fullmac bus interface
refactoring.
Reviewed-by: default avatarPieter-Paul Giesberts <pieterpg@broadcom.com>
Reviewed-by: default avatarAlwin Beukers <alwin@broadcom.com>
Reviewed-by: default avatarArend van Spriel <arend@broadcom.com>
Signed-off-by: default avatarFranky Lin <frankyl@broadcom.com>
Signed-off-by: default avatarJohn W. Linville <linville@tuxdriver.com>
parent e92eedf4
...@@ -40,7 +40,8 @@ ...@@ -40,7 +40,8 @@
static void brcmf_sdioh_irqhandler(struct sdio_func *func) static void brcmf_sdioh_irqhandler(struct sdio_func *func)
{ {
struct brcmf_sdio_dev *sdiodev = dev_get_drvdata(&func->card->dev); struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev);
struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv;
brcmf_dbg(TRACE, "***IRQHandler\n"); brcmf_dbg(TRACE, "***IRQHandler\n");
......
...@@ -461,6 +461,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -461,6 +461,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
{ {
int ret = 0; int ret = 0;
struct brcmf_sdio_dev *sdiodev; struct brcmf_sdio_dev *sdiodev;
struct brcmf_bus *bus_if;
brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(TRACE, "Enter\n");
brcmf_dbg(TRACE, "func->class=%x\n", func->class); brcmf_dbg(TRACE, "func->class=%x\n", func->class);
brcmf_dbg(TRACE, "sdio_vendor: 0x%04x\n", func->vendor); brcmf_dbg(TRACE, "sdio_vendor: 0x%04x\n", func->vendor);
...@@ -472,12 +473,18 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -472,12 +473,18 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
brcmf_dbg(ERROR, "card private drvdata occupied\n"); brcmf_dbg(ERROR, "card private drvdata occupied\n");
return -ENXIO; return -ENXIO;
} }
bus_if = kzalloc(sizeof(struct brcmf_bus), GFP_KERNEL);
if (!bus_if)
return -ENOMEM;
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->dev = &func->card->dev;
sdiodev->func[0] = func->card->sdio_func[0]; sdiodev->func[0] = func->card->sdio_func[0];
sdiodev->func[1] = func; sdiodev->func[1] = func;
dev_set_drvdata(&func->card->dev, sdiodev); bus_if->bus_priv = sdiodev;
bus_if->type = SDIO_BUS;
dev_set_drvdata(&func->card->dev, bus_if);
atomic_set(&sdiodev->suspend, false); atomic_set(&sdiodev->suspend, false);
init_waitqueue_head(&sdiodev->request_byte_wait); init_waitqueue_head(&sdiodev->request_byte_wait);
...@@ -487,7 +494,8 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -487,7 +494,8 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
} }
if (func->num == 2) { if (func->num == 2) {
sdiodev = dev_get_drvdata(&func->card->dev); bus_if = dev_get_drvdata(&func->card->dev);
sdiodev = bus_if->bus_priv;
if ((!sdiodev) || (sdiodev->func[1]->card != func->card)) if ((!sdiodev) || (sdiodev->func[1]->card != func->card))
return -ENODEV; return -ENODEV;
sdiodev->func[2] = func; sdiodev->func[2] = func;
...@@ -501,6 +509,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func, ...@@ -501,6 +509,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
static void brcmf_ops_sdio_remove(struct sdio_func *func) static void brcmf_ops_sdio_remove(struct sdio_func *func)
{ {
struct brcmf_bus *bus_if;
struct brcmf_sdio_dev *sdiodev; struct brcmf_sdio_dev *sdiodev;
brcmf_dbg(TRACE, "Enter\n"); brcmf_dbg(TRACE, "Enter\n");
brcmf_dbg(INFO, "func->class=%x\n", func->class); brcmf_dbg(INFO, "func->class=%x\n", func->class);
...@@ -509,10 +518,12 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func) ...@@ -509,10 +518,12 @@ static void brcmf_ops_sdio_remove(struct sdio_func *func)
brcmf_dbg(INFO, "Function#: 0x%04x\n", func->num); brcmf_dbg(INFO, "Function#: 0x%04x\n", func->num);
if (func->num == 2) { if (func->num == 2) {
sdiodev = dev_get_drvdata(&func->card->dev); bus_if = dev_get_drvdata(&func->card->dev);
sdiodev = bus_if->bus_priv;
brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_remove...\n"); brcmf_dbg(TRACE, "F2 found, calling brcmf_sdio_remove...\n");
brcmf_sdio_remove(sdiodev); brcmf_sdio_remove(sdiodev);
dev_set_drvdata(&func->card->dev, NULL); dev_set_drvdata(&func->card->dev, NULL);
kfree(bus_if);
kfree(sdiodev); kfree(sdiodev);
} }
} }
...@@ -523,11 +534,12 @@ static int brcmf_sdio_suspend(struct device *dev) ...@@ -523,11 +534,12 @@ static int brcmf_sdio_suspend(struct device *dev)
mmc_pm_flag_t sdio_flags; mmc_pm_flag_t sdio_flags;
struct brcmf_sdio_dev *sdiodev; struct brcmf_sdio_dev *sdiodev;
struct sdio_func *func = dev_to_sdio_func(dev); struct sdio_func *func = dev_to_sdio_func(dev);
struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev);
int ret = 0; int ret = 0;
brcmf_dbg(TRACE, "\n"); brcmf_dbg(TRACE, "\n");
sdiodev = dev_get_drvdata(&func->card->dev); sdiodev = bus_if->bus_priv;
atomic_set(&sdiodev->suspend, true); atomic_set(&sdiodev->suspend, true);
...@@ -552,8 +564,9 @@ static int brcmf_sdio_resume(struct device *dev) ...@@ -552,8 +564,9 @@ static int brcmf_sdio_resume(struct device *dev)
{ {
struct brcmf_sdio_dev *sdiodev; struct brcmf_sdio_dev *sdiodev;
struct sdio_func *func = dev_to_sdio_func(dev); struct sdio_func *func = dev_to_sdio_func(dev);
struct brcmf_bus *bus_if = dev_get_drvdata(&func->card->dev);
sdiodev = dev_get_drvdata(&func->card->dev); sdiodev = bus_if->bus_priv;
brcmf_sdio_wdtmr_enable(sdiodev, true); brcmf_sdio_wdtmr_enable(sdiodev, true);
atomic_set(&sdiodev->suspend, false); atomic_set(&sdiodev->suspend, false);
return 0; return 0;
......
...@@ -571,6 +571,11 @@ struct brcmf_dcmd { ...@@ -571,6 +571,11 @@ struct brcmf_dcmd {
uint needed; /* bytes needed (optional) */ uint needed; /* bytes needed (optional) */
}; };
struct brcmf_bus {
u8 type; /* bus type */
void *bus_priv; /* pointer to bus private structure */
};
/* Forward decls for struct brcmf_pub (see below) */ /* Forward decls for struct brcmf_pub (see below) */
struct brcmf_sdio; /* device bus info */ struct brcmf_sdio; /* device bus info */
struct brcmf_proto; /* device communication protocol info */ struct brcmf_proto; /* device communication protocol info */
......
...@@ -134,7 +134,7 @@ struct brcmf_sdio_dev { ...@@ -134,7 +134,7 @@ struct brcmf_sdio_dev {
wait_queue_head_t request_word_wait; wait_queue_head_t request_word_wait;
wait_queue_head_t request_chain_wait; wait_queue_head_t request_chain_wait;
wait_queue_head_t request_buffer_wait; wait_queue_head_t request_buffer_wait;
struct device *dev;
}; };
/* Register/deregister device interrupt handler. */ /* Register/deregister device interrupt handler. */
......
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