Message ID | 1480517537-9920-1-git-send-email-akarwar@marvell.com (mailing list archive) |
---|---|
State | Accepted |
Commit | 90ff71f9557591218b5fce1ce7b67afd4cf83894 |
Delegated to: | Kalle Valo |
Headers | show |
Amitkumar Karwar <akarwar@marvell.com> wrote: > From: Xinming Hu <huxm@marvell.com> > > Next patch in this series is going to use mwifiex_read_reg() in remove > handlers. The changes here are prerequisites to avoid forward > declarations. > > Signed-off-by: Xinming Hu <huxm@marvell.com> > Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Failed to apply: fatal: sha1 information is lacking or useless (drivers/net/wireless/marvell/mwifiex/pcie.c). Applying: mwifiex: get rid of global user_rmmod flag Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0001 mwifiex: get rid of global user_rmmod flag 2 patches set to Changes Requested. 9454491 [1/2] mwifiex: code rearrangement in pcie.c and sdio.c 9454493 [2/2] mwifiex: get rid of global user_rmmod flag
Hi Kalle, > From: linux-wireless-owner@vger.kernel.org [mailto:linux-wireless- > owner@vger.kernel.org] On Behalf Of Kalle Valo > Sent: Monday, December 05, 2016 4:39 PM > To: Amitkumar Karwar > Cc: linux-wireless@vger.kernel.org; Cathy Luo; Nishant Sarmukadam; > rajatja@google.com; briannorris@google.com; dmitry.torokhov@gmail.com; > Xinming Hu; Amitkumar Karwar > Subject: Re: [1/2] mwifiex: code rearrangement in pcie.c and sdio.c > > Amitkumar Karwar <akarwar@marvell.com> wrote: > > From: Xinming Hu <huxm@marvell.com> > > > > Next patch in this series is going to use mwifiex_read_reg() in > remove > > handlers. The changes here are prerequisites to avoid forward > > declarations. > > > > Signed-off-by: Xinming Hu <huxm@marvell.com> > > Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> > > Failed to apply: > > fatal: sha1 information is lacking or useless > (drivers/net/wireless/marvell/mwifiex/pcie.c). > Applying: mwifiex: get rid of global user_rmmod flag Repository lacks > necessary blobs to fall back on 3-way merge. > Cannot fall back to three-way merge. > Patch failed at 0001 mwifiex: get rid of global user_rmmod flag > > 2 patches set to Changes Requested. > > 9454491 [1/2] mwifiex: code rearrangement in pcie.c and sdio.c > 9454493 [2/2] mwifiex: get rid of global user_rmmod flag > > -- > https://patchwork.kernel.org/patch/9454491/ > > Documentation about submitting wireless patches and checking status > from patchwork: > > https://wireless.wiki.kernel.org/en/developers/documentation/submitting > patches These two patches have dependency with other patch series. I want you to consider patches in following order(first being recent). mwifiex: sdio: fix use after free issue for save_adapter mwifiex: use module_*_driver helper macros [2/2] mwifiex: get rid of global user_rmmod flag [1/2] mwifiex: code rearrangement in pcie.c and sdio.c [v3,5/5] mwifiex: move pcie_work and related variables inside card -------- This series can be accepted if there are no further concerns/comments from Brian/Dmitry. [v3,4/5] mwifiex: wait firmware dump complete during card remove process [v3,3/5] mwifiex: get rid of drv_info* adapter variables [v3,2/5] mwifiex: do not free firmware dump memory in shutdown_drv [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv Regards, Amitkumar
Amitkumar Karwar <akarwar@marvell.com> wrote: > From: Xinming Hu <huxm@marvell.com> > > Next patch in this series is going to use mwifiex_read_reg() in remove > handlers. The changes here are prerequisites to avoid forward > declarations. > > Signed-off-by: Xinming Hu <huxm@marvell.com> > Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> Patch 2 doesn't apply. fatal: sha1 information is lacking or useless (drivers/net/wireless/marvell/mwifiex/pcie.c). Applying: mwifiex: get rid of global user_rmmod flag Repository lacks necessary blobs to fall back on 3-way merge. Cannot fall back to three-way merge. Patch failed at 0001 mwifiex: get rid of global user_rmmod flag 2 patches set to Changes Requested. 9454491 [1/2] mwifiex: code rearrangement in pcie.c and sdio.c 9454493 [2/2] mwifiex: get rid of global user_rmmod flag
Amitkumar Karwar <akarwar@marvell.com> writes: > Hi Kalle, > >> Failed to apply: >> >> fatal: sha1 information is lacking or useless >> (drivers/net/wireless/marvell/mwifiex/pcie.c). >> Applying: mwifiex: get rid of global user_rmmod flag Repository lacks >> necessary blobs to fall back on 3-way merge. >> Cannot fall back to three-way merge. >> Patch failed at 0001 mwifiex: get rid of global user_rmmod flag >> >> 2 patches set to Changes Requested. >> >> 9454491 [1/2] mwifiex: code rearrangement in pcie.c and sdio.c >> 9454493 [2/2] mwifiex: get rid of global user_rmmod flag >> >> -- >> https://patchwork.kernel.org/patch/9454491/ >> >> Documentation about submitting wireless patches and checking status >> from patchwork: >> >> https://wireless.wiki.kernel.org/en/developers/documentation/submitting >> patches > > > These two patches have dependency with other patch series. I want you to consider patches in following order(first being recent). > > mwifiex: sdio: fix use after free issue for save_adapter This applied fine. > mwifiex: use module_*_driver helper macros > > [2/2] mwifiex: get rid of global user_rmmod flag > [1/2] mwifiex: code rearrangement in pcie.c and sdio.c > > [v3,5/5] mwifiex: move pcie_work and related variables inside card -------- This series can be accepted if there are no further concerns/comments from Brian/Dmitry. > [v3,4/5] mwifiex: wait firmware dump complete during card remove process > [v3,3/5] mwifiex: get rid of drv_info* adapter variables > [v3,2/5] mwifiex: do not free firmware dump memory in shutdown_drv > [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv But these didn't. Can you please rebase these and resubmit in one patchset? Less conflicts that way.
Hi Kalle, > From: Kalle Valo [mailto:kvalo@codeaurora.org] > Sent: Friday, December 30, 2016 4:58 PM > To: Amitkumar Karwar > Cc: linux-wireless@vger.kernel.org; Cathy Luo; Nishant Sarmukadam; > rajatja@google.com; briannorris@google.com; dmitry.torokhov@gmail.com; > Xinming Hu > Subject: [EXT] Re: [1/2] mwifiex: code rearrangement in pcie.c and > sdio.c > > Amitkumar Karwar <akarwar@marvell.com> writes: > > > Hi Kalle, > > > >> Failed to apply: > >> > >> fatal: sha1 information is lacking or useless > >> (drivers/net/wireless/marvell/mwifiex/pcie.c). > >> Applying: mwifiex: get rid of global user_rmmod flag Repository > lacks > >> necessary blobs to fall back on 3-way merge. > >> Cannot fall back to three-way merge. > >> Patch failed at 0001 mwifiex: get rid of global user_rmmod flag > >> > >> 2 patches set to Changes Requested. > >> > >> 9454491 [1/2] mwifiex: code rearrangement in pcie.c and sdio.c > >> 9454493 [2/2] mwifiex: get rid of global user_rmmod flag > >> > >> -- > >> https://patchwork.kernel.org/patch/9454491/ > >> > >> Documentation about submitting wireless patches and checking status > >> from patchwork: > >> > >> > https://wireless.wiki.kernel.org/en/developers/documentation/submitti > >> ng > >> patches > > > > > > These two patches have dependency with other patch series. I want you > to consider patches in following order(first being recent). > > > > mwifiex: sdio: fix use after free issue for save_adapter > > This applied fine. > > > mwifiex: use module_*_driver helper macros > > > > [2/2] mwifiex: get rid of global user_rmmod flag [1/2] mwifiex: code > > rearrangement in pcie.c and sdio.c > > > > [v3,5/5] mwifiex: move pcie_work and related variables inside card -- > ------ This series can be accepted if there are no further > concerns/comments from Brian/Dmitry. > > [v3,4/5] mwifiex: wait firmware dump complete during card remove > > process [v3,3/5] mwifiex: get rid of drv_info* adapter variables > > [v3,2/5] mwifiex: do not free firmware dump memory in shutdown_drv > > [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv > > But these didn't. Can you please rebase these and resubmit in one > patchset? Less conflicts that way. > The problem here is you tried to apply the patches in reverse order. Sorry for the confusion. Please apply pending patches in below order. [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv --- Apply this patch first. [v3,2/5] mwifiex: do not free firmware dump memory in shutdown_drv [v3,3/5] mwifiex: get rid of drv_info* adapter variables [v3,4/5] mwifiex: wait firmware dump complete during card remove process [v3,5/5] mwifiex: move pcie_work and related variables inside card [1/2] mwifiex: code rearrangement in pcie.c and sdio.c [2/2] mwifiex: get rid of global user_rmmod flag mwifiex: use module_*_driver helper macros [1/5] mwifiex: get rid of mwifiex_do_flr wrapper [2/5] mwifiex: cleanup in PCIe flr code path [3/5] mwifiex: sdio card reset enhancement [4/5] mwifiex: get rid of __mwifiex_sdio_remove helper [5/5] mwifiex: get rid of global save_adapter and sdio_work Regards, Amitkumar
Amitkumar Karwar <akarwar@marvell.com> wrote: > From: Xinming Hu <huxm@marvell.com> > > Next patch in this series is going to use mwifiex_read_reg() in remove > handlers. The changes here are prerequisites to avoid forward > declarations. > > Signed-off-by: Xinming Hu <huxm@marvell.com> > Signed-off-by: Amitkumar Karwar <akarwar@marvell.com> 2 patches applied to wireless-drivers-next.git, thanks. 90ff71f95575 mwifiex: code rearrangement in pcie.c and sdio.c 045f0c1b5e26 mwifiex: get rid of global user_rmmod flag
Amitkumar Karwar <akarwar@marvell.com> writes: >> But these didn't. Can you please rebase these and resubmit in one >> patchset? Less conflicts that way. >> > > The problem here is you tried to apply the patches in reverse order. Sorry for the confusion. > Please apply pending patches in below order. > > [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv --- Apply this patch first. > [v3,2/5] mwifiex: do not free firmware dump memory in shutdown_drv > [v3,3/5] mwifiex: get rid of drv_info* adapter variables > [v3,4/5] mwifiex: wait firmware dump complete during card remove process > [v3,5/5] mwifiex: move pcie_work and related variables inside card > > [1/2] mwifiex: code rearrangement in pcie.c and sdio.c > [2/2] mwifiex: get rid of global user_rmmod flag > > mwifiex: use module_*_driver helper macros > > [1/5] mwifiex: get rid of mwifiex_do_flr wrapper > [2/5] mwifiex: cleanup in PCIe flr code path > [3/5] mwifiex: sdio card reset enhancement > [4/5] mwifiex: get rid of __mwifiex_sdio_remove helper > [5/5] mwifiex: get rid of global save_adapter and sdio_work Thanks, now I was able to apply these but please do double check the result in wireless-drivers-next. I also noticed a new warning: drivers/net/wireless/marvell/mwifiex/pcie.c: In function 'mwifiex_pcie_remove': drivers/net/wireless/marvell/mwifiex/pcie.c:303:5: warning: 'fw_status' may be used uninitialized in this function [-Wmaybe-uninitialized] if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) { Actually I'm not sure if this warning was caused by these patches as I have recently updated my ancient gcc to a newer one (5.4.0), but please take a look and send a fix if it's a valid warning.
Hi Kalle, > From: Kalle Valo [mailto:kvalo@codeaurora.org] > Sent: Thursday, January 12, 2017 8:25 PM > To: Amitkumar Karwar > Cc: linux-wireless@vger.kernel.org; Cathy Luo; Nishant Sarmukadam; > rajatja@google.com; briannorris@google.com; dmitry.torokhov@gmail.com; > Xinming Hu > Subject: Re: [1/2] mwifiex: code rearrangement in pcie.c and sdio.c > > Amitkumar Karwar <akarwar@marvell.com> writes: > > >> But these didn't. Can you please rebase these and resubmit in one > >> patchset? Less conflicts that way. > >> > > > > The problem here is you tried to apply the patches in reverse order. > Sorry for the confusion. > > Please apply pending patches in below order. > > > > [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv --- > Apply this patch first. > > [v3,2/5] mwifiex: do not free firmware dump memory in shutdown_drv > > [v3,3/5] mwifiex: get rid of drv_info* adapter variables [v3,4/5] > > mwifiex: wait firmware dump complete during card remove process > > [v3,5/5] mwifiex: move pcie_work and related variables inside card > > > > [1/2] mwifiex: code rearrangement in pcie.c and sdio.c [2/2] mwifiex: > > get rid of global user_rmmod flag > > > > mwifiex: use module_*_driver helper macros > > > > [1/5] mwifiex: get rid of mwifiex_do_flr wrapper [2/5] mwifiex: > > cleanup in PCIe flr code path [3/5] mwifiex: sdio card reset > > enhancement [4/5] mwifiex: get rid of __mwifiex_sdio_remove helper > > [5/5] mwifiex: get rid of global save_adapter and sdio_work > > Thanks, now I was able to apply these but please do double check the > result in wireless-drivers-next. > > I also noticed a new warning: > > drivers/net/wireless/marvell/mwifiex/pcie.c: In function > 'mwifiex_pcie_remove': > drivers/net/wireless/marvell/mwifiex/pcie.c:303:5: warning: 'fw_status' > may be used uninitialized in this function [-Wmaybe-uninitialized] > if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) { > > Actually I'm not sure if this warning was caused by these patches as I > have recently updated my ancient gcc to a newer one (5.4.0), but please > take a look and send a fix if it's a valid warning. > Below CL fixes this warning. https://patchwork.kernel.org/patch/9515899/ Regards, Amitkumar
Amitkumar Karwar <akarwar@marvell.com> writes: > Hi Kalle, > >> From: Kalle Valo [mailto:kvalo@codeaurora.org] >> Sent: Thursday, January 12, 2017 8:25 PM >> To: Amitkumar Karwar >> Cc: linux-wireless@vger.kernel.org; Cathy Luo; Nishant Sarmukadam; >> rajatja@google.com; briannorris@google.com; dmitry.torokhov@gmail.com; >> Xinming Hu >> Subject: Re: [1/2] mwifiex: code rearrangement in pcie.c and sdio.c >> >> Amitkumar Karwar <akarwar@marvell.com> writes: >> >> >> But these didn't. Can you please rebase these and resubmit in one >> >> patchset? Less conflicts that way. >> >> >> > >> > The problem here is you tried to apply the patches in reverse order. >> Sorry for the confusion. >> > Please apply pending patches in below order. >> > >> > [v3,1/5] mwifiex: don't wait for main_process in shutdown_drv --- >> Apply this patch first. >> > [v3,2/5] mwifiex: do not free firmware dump memory in shutdown_drv >> > [v3,3/5] mwifiex: get rid of drv_info* adapter variables [v3,4/5] >> > mwifiex: wait firmware dump complete during card remove process >> > [v3,5/5] mwifiex: move pcie_work and related variables inside card >> > >> > [1/2] mwifiex: code rearrangement in pcie.c and sdio.c [2/2] mwifiex: >> > get rid of global user_rmmod flag >> > >> > mwifiex: use module_*_driver helper macros >> > >> > [1/5] mwifiex: get rid of mwifiex_do_flr wrapper [2/5] mwifiex: >> > cleanup in PCIe flr code path [3/5] mwifiex: sdio card reset >> > enhancement [4/5] mwifiex: get rid of __mwifiex_sdio_remove helper >> > [5/5] mwifiex: get rid of global save_adapter and sdio_work >> >> Thanks, now I was able to apply these but please do double check the >> result in wireless-drivers-next. >> >> I also noticed a new warning: >> >> drivers/net/wireless/marvell/mwifiex/pcie.c: In function >> 'mwifiex_pcie_remove': >> drivers/net/wireless/marvell/mwifiex/pcie.c:303:5: warning: 'fw_status' >> may be used uninitialized in this function [-Wmaybe-uninitialized] >> if (fw_status == FIRMWARE_READY_PCIE && !adapter->mfg_mode) { >> >> Actually I'm not sure if this warning was caused by these patches as I >> have recently updated my ancient gcc to a newer one (5.4.0), but please >> take a look and send a fix if it's a valid warning. >> > > Below CL fixes this warning. > > https://patchwork.kernel.org/patch/9515899/ Good, thanks. I'll apply that shortly.
diff --git a/drivers/net/wireless/marvell/mwifiex/pcie.c b/drivers/net/wireless/marvell/mwifiex/pcie.c index 32fa4ed..7aa16a5 100644 --- a/drivers/net/wireless/marvell/mwifiex/pcie.c +++ b/drivers/net/wireless/marvell/mwifiex/pcie.c @@ -81,6 +81,42 @@ static void mwifiex_unmap_pci_memory(struct mwifiex_adapter *adapter, } /* + * This function writes data into PCIE card register. + */ +static int mwifiex_write_reg(struct mwifiex_adapter *adapter, int reg, u32 data) +{ + struct pcie_service_card *card = adapter->card; + + iowrite32(data, card->pci_mmap1 + reg); + + return 0; +} + +/* This function reads data from PCIE card register. + */ +static int mwifiex_read_reg(struct mwifiex_adapter *adapter, int reg, u32 *data) +{ + struct pcie_service_card *card = adapter->card; + + *data = ioread32(card->pci_mmap1 + reg); + if (*data == 0xffffffff) + return 0xffffffff; + + return 0; +} + +/* This function reads u8 data from PCIE card register. */ +static int mwifiex_read_reg_byte(struct mwifiex_adapter *adapter, + int reg, u8 *data) +{ + struct pcie_service_card *card = adapter->card; + + *data = ioread8(card->pci_mmap1 + reg); + + return 0; +} + +/* * This function reads sleep cookie and checks if FW is ready */ static bool mwifiex_pcie_ok_to_access_hw(struct mwifiex_adapter *adapter) @@ -374,43 +410,6 @@ static SIMPLE_DEV_PM_OPS(mwifiex_pcie_pm_ops, mwifiex_pcie_suspend, }; /* - * This function writes data into PCIE card register. - */ -static int mwifiex_write_reg(struct mwifiex_adapter *adapter, int reg, u32 data) -{ - struct pcie_service_card *card = adapter->card; - - iowrite32(data, card->pci_mmap1 + reg); - - return 0; -} - -/* - * This function reads data from PCIE card register. - */ -static int mwifiex_read_reg(struct mwifiex_adapter *adapter, int reg, u32 *data) -{ - struct pcie_service_card *card = adapter->card; - - *data = ioread32(card->pci_mmap1 + reg); - if (*data == 0xffffffff) - return 0xffffffff; - - return 0; -} - -/* This function reads u8 data from PCIE card register. */ -static int mwifiex_read_reg_byte(struct mwifiex_adapter *adapter, - int reg, u8 *data) -{ - struct pcie_service_card *card = adapter->card; - - *data = ioread8(card->pci_mmap1 + reg); - - return 0; -} - -/* * This function adds delay loop to ensure FW is awake before proceeding. */ static void mwifiex_pcie_dev_wakeup_delay(struct mwifiex_adapter *adapter) diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index 66d0dd6..6fcaf26 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c @@ -215,6 +215,171 @@ static int mwifiex_sdio_resume(struct device *dev) return 0; } +/* Write data into SDIO card register. Caller claims SDIO device. */ +static int +mwifiex_write_reg_locked(struct sdio_func *func, u32 reg, u8 data) +{ + int ret = -1; + + sdio_writeb(func, data, reg, &ret); + return ret; +} + +/* This function writes data into SDIO card register. + */ +static int +mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u8 data) +{ + struct sdio_mmc_card *card = adapter->card; + int ret; + + sdio_claim_host(card->func); + ret = mwifiex_write_reg_locked(card->func, reg, data); + sdio_release_host(card->func); + + return ret; +} + +/* This function reads data from SDIO card register. + */ +static int +mwifiex_read_reg(struct mwifiex_adapter *adapter, u32 reg, u8 *data) +{ + struct sdio_mmc_card *card = adapter->card; + int ret = -1; + u8 val; + + sdio_claim_host(card->func); + val = sdio_readb(card->func, reg, &ret); + sdio_release_host(card->func); + + *data = val; + + return ret; +} + +/* This function writes multiple data into SDIO card memory. + * + * This does not work in suspended mode. + */ +static int +mwifiex_write_data_sync(struct mwifiex_adapter *adapter, + u8 *buffer, u32 pkt_len, u32 port) +{ + struct sdio_mmc_card *card = adapter->card; + int ret; + u8 blk_mode = + (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE : BLOCK_MODE; + u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1; + u32 blk_cnt = + (blk_mode == + BLOCK_MODE) ? (pkt_len / + MWIFIEX_SDIO_BLOCK_SIZE) : pkt_len; + u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK); + + if (adapter->is_suspended) { + mwifiex_dbg(adapter, ERROR, + "%s: not allowed while suspended\n", __func__); + return -1; + } + + sdio_claim_host(card->func); + + ret = sdio_writesb(card->func, ioport, buffer, blk_cnt * blk_size); + + sdio_release_host(card->func); + + return ret; +} + +/* This function reads multiple data from SDIO card memory. + */ +static int mwifiex_read_data_sync(struct mwifiex_adapter *adapter, u8 *buffer, + u32 len, u32 port, u8 claim) +{ + struct sdio_mmc_card *card = adapter->card; + int ret; + u8 blk_mode = (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE + : BLOCK_MODE; + u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1; + u32 blk_cnt = (blk_mode == BLOCK_MODE) ? (len / MWIFIEX_SDIO_BLOCK_SIZE) + : len; + u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK); + + if (claim) + sdio_claim_host(card->func); + + ret = sdio_readsb(card->func, buffer, ioport, blk_cnt * blk_size); + + if (claim) + sdio_release_host(card->func); + + return ret; +} + +/* This function reads the firmware status. + */ +static int +mwifiex_sdio_read_fw_status(struct mwifiex_adapter *adapter, u16 *dat) +{ + struct sdio_mmc_card *card = adapter->card; + const struct mwifiex_sdio_card_reg *reg = card->reg; + u8 fws0, fws1; + + if (mwifiex_read_reg(adapter, reg->status_reg_0, &fws0)) + return -1; + + if (mwifiex_read_reg(adapter, reg->status_reg_1, &fws1)) + return -1; + + *dat = (u16)((fws1 << 8) | fws0); + return 0; +} + +/* This function checks the firmware status in card. + */ +static int mwifiex_check_fw_status(struct mwifiex_adapter *adapter, + u32 poll_num) +{ + int ret = 0; + u16 firmware_stat; + u32 tries; + + for (tries = 0; tries < poll_num; tries++) { + ret = mwifiex_sdio_read_fw_status(adapter, &firmware_stat); + if (ret) + continue; + if (firmware_stat == FIRMWARE_READY_SDIO) { + ret = 0; + break; + } + + msleep(100); + ret = -1; + } + + return ret; +} + +/* This function checks if WLAN is the winner. + */ +static int mwifiex_check_winner_status(struct mwifiex_adapter *adapter) +{ + int ret = 0; + u8 winner = 0; + struct sdio_mmc_card *card = adapter->card; + + if (mwifiex_read_reg(adapter, card->reg->status_reg_0, &winner)) + return -1; + + if (winner) + adapter->winner = 0; + else + adapter->winner = 1; + + return ret; +} + /* * SDIO remove. * @@ -374,111 +539,6 @@ static int mwifiex_sdio_suspend(struct device *dev) } }; -/* Write data into SDIO card register. Caller claims SDIO device. */ -static int -mwifiex_write_reg_locked(struct sdio_func *func, u32 reg, u8 data) -{ - int ret = -1; - sdio_writeb(func, data, reg, &ret); - return ret; -} - -/* - * This function writes data into SDIO card register. - */ -static int -mwifiex_write_reg(struct mwifiex_adapter *adapter, u32 reg, u8 data) -{ - struct sdio_mmc_card *card = adapter->card; - int ret; - - sdio_claim_host(card->func); - ret = mwifiex_write_reg_locked(card->func, reg, data); - sdio_release_host(card->func); - - return ret; -} - -/* - * This function reads data from SDIO card register. - */ -static int -mwifiex_read_reg(struct mwifiex_adapter *adapter, u32 reg, u8 *data) -{ - struct sdio_mmc_card *card = adapter->card; - int ret = -1; - u8 val; - - sdio_claim_host(card->func); - val = sdio_readb(card->func, reg, &ret); - sdio_release_host(card->func); - - *data = val; - - return ret; -} - -/* - * This function writes multiple data into SDIO card memory. - * - * This does not work in suspended mode. - */ -static int -mwifiex_write_data_sync(struct mwifiex_adapter *adapter, - u8 *buffer, u32 pkt_len, u32 port) -{ - struct sdio_mmc_card *card = adapter->card; - int ret; - u8 blk_mode = - (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE : BLOCK_MODE; - u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1; - u32 blk_cnt = - (blk_mode == - BLOCK_MODE) ? (pkt_len / - MWIFIEX_SDIO_BLOCK_SIZE) : pkt_len; - u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK); - - if (adapter->is_suspended) { - mwifiex_dbg(adapter, ERROR, - "%s: not allowed while suspended\n", __func__); - return -1; - } - - sdio_claim_host(card->func); - - ret = sdio_writesb(card->func, ioport, buffer, blk_cnt * blk_size); - - sdio_release_host(card->func); - - return ret; -} - -/* - * This function reads multiple data from SDIO card memory. - */ -static int mwifiex_read_data_sync(struct mwifiex_adapter *adapter, u8 *buffer, - u32 len, u32 port, u8 claim) -{ - struct sdio_mmc_card *card = adapter->card; - int ret; - u8 blk_mode = (port & MWIFIEX_SDIO_BYTE_MODE_MASK) ? BYTE_MODE - : BLOCK_MODE; - u32 blk_size = (blk_mode == BLOCK_MODE) ? MWIFIEX_SDIO_BLOCK_SIZE : 1; - u32 blk_cnt = (blk_mode == BLOCK_MODE) ? (len / MWIFIEX_SDIO_BLOCK_SIZE) - : len; - u32 ioport = (port & MWIFIEX_SDIO_IO_PORT_MASK); - - if (claim) - sdio_claim_host(card->func); - - ret = sdio_readsb(card->func, buffer, ioport, blk_cnt * blk_size); - - if (claim) - sdio_release_host(card->func); - - return ret; -} - /* * This function wakes up the card. * @@ -765,27 +825,6 @@ static int mwifiex_get_wr_port_data(struct mwifiex_adapter *adapter, u32 *port) } /* - * This function reads the firmware status. - */ -static int -mwifiex_sdio_read_fw_status(struct mwifiex_adapter *adapter, u16 *dat) -{ - struct sdio_mmc_card *card = adapter->card; - const struct mwifiex_sdio_card_reg *reg = card->reg; - u8 fws0, fws1; - - if (mwifiex_read_reg(adapter, reg->status_reg_0, &fws0)) - return -1; - - if (mwifiex_read_reg(adapter, reg->status_reg_1, &fws1)) - return -1; - - *dat = (u16) ((fws1 << 8) | fws0); - - return 0; -} - -/* * This function disables the host interrupt. * * The host interrupt mask is read, the disable bit is reset and @@ -1090,51 +1129,6 @@ static int mwifiex_prog_fw_w_helper(struct mwifiex_adapter *adapter, } /* - * This function checks the firmware status in card. - */ -static int mwifiex_check_fw_status(struct mwifiex_adapter *adapter, - u32 poll_num) -{ - int ret = 0; - u16 firmware_stat; - u32 tries; - - for (tries = 0; tries < poll_num; tries++) { - ret = mwifiex_sdio_read_fw_status(adapter, &firmware_stat); - if (ret) - continue; - if (firmware_stat == FIRMWARE_READY_SDIO) { - ret = 0; - break; - } else { - msleep(100); - ret = -1; - } - } - - return ret; -} - -/* This function checks if WLAN is the winner. - */ -static int mwifiex_check_winner_status(struct mwifiex_adapter *adapter) -{ - int ret = 0; - u8 winner = 0; - struct sdio_mmc_card *card = adapter->card; - - if (mwifiex_read_reg(adapter, card->reg->status_reg_0, &winner)) - return -1; - - if (winner) - adapter->winner = 0; - else - adapter->winner = 1; - - return ret; -} - -/* * This function decode sdio aggreation pkt. * * Based on the the data block size and pkt_len,