From 1bb1f38462bcf58cf98d8f7bedf2bfefd394f940 Mon Sep 17 00:00:00 2001 From: Arend van Spriel Date: Thu, 9 Feb 2012 21:09:05 +0100 Subject: [PATCH] brcm80211: fmac: update bus state in common driver part The bus state is updated in the sdio bus init function, but it is better to do it when the brcmf_bus_start() function is completed successfully. The brcmf_netdev_open() function will return -EAGAIN until the state is updated instead of calling brcmf_bus_start() to avoid reentering that function. Reviewed-by: Pieter-Paul Giesberts Reviewed-by: Franky (Zhenhui) Lin Signed-off-by: Arend van Spriel Signed-off-by: John W. Linville --- .../wireless/brcm80211/brcmfmac/dhd_linux.c | 19 ++++++++----------- .../wireless/brcm80211/brcmfmac/dhd_sdio.c | 3 --- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c index ff7fc0e9f807..68da7568ad10 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_linux.c @@ -796,18 +796,19 @@ static int brcmf_netdev_open(struct net_device *ndev) { struct brcmf_if *ifp = netdev_priv(ndev); struct brcmf_pub *drvr = ifp->drvr; + struct brcmf_bus *bus_if = drvr->bus_if; u32 toe_ol; s32 ret = 0; brcmf_dbg(TRACE, "ifidx %d\n", ifp->idx); if (ifp->idx == 0) { /* do it only for primary eth0 */ - /* try to bring up bus */ - ret = brcmf_bus_start(drvr->dev); - if (ret != 0) { - brcmf_dbg(ERROR, "failed with code %d\n", ret); - return -1; + /* If bus is not ready, can't continue */ + if (bus_if->state != BRCMF_BUS_DATA) { + brcmf_dbg(ERROR, "failed bus is not ready\n"); + return -EAGAIN; } + atomic_set(&drvr->pend_8021x_cnt, 0); memcpy(ndev->dev_addr, drvr->mac, ETH_ALEN); @@ -979,12 +980,6 @@ int brcmf_bus_start(struct device *dev) return ret; } - /* If bus is not ready, can't come up */ - if (bus_if->state != BRCMF_BUS_DATA) { - brcmf_dbg(ERROR, "failed bus is not ready\n"); - return -ENODEV; - } - brcmf_c_mkiovar("event_msgs", drvr->eventmask, BRCMF_EVENTING_MASK_LEN, iovbuf, sizeof(iovbuf)); brcmf_proto_cdc_query_dcmd(drvr, 0, BRCMF_C_GET_VAR, iovbuf, @@ -1021,6 +1016,8 @@ int brcmf_bus_start(struct device *dev) if (ret < 0) return ret; + /* signal bus ready */ + bus_if->state = BRCMF_BUS_DATA; return 0; } diff --git a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c index 47a192db36ff..253fc20adf88 100644 --- a/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c +++ b/drivers/net/wireless/brcm80211/brcmfmac/dhd_sdio.c @@ -3464,9 +3464,6 @@ static int brcmf_sdbrcm_bus_init(struct device *dev) brcmf_sdcard_cfg_write(bus->sdiodev, SDIO_FUNC_1, SBSDIO_WATERMARK, 8, &err); - - /* Set bus state according to enable result */ - bus_if->state = BRCMF_BUS_DATA; } else { /* Disable F2 again */ enable = SDIO_FUNC_ENABLE_1; -- 2.34.1