rsi: correct SDIO disconnect path handling
authorKarun Eagalapati <karun256@gmail.com>
Thu, 6 Jul 2017 14:37:08 +0000 (20:07 +0530)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 28 Jul 2017 14:22:34 +0000 (17:22 +0300)
Sometimes it's observed that we get interrupt/Rx frame when device is
already detached from mac80211. In this case couple of error messages
are displayed in dmesg log. This patch corrects the order so that
disconnection will happen cleanly

Signed-off-by: Karun Eagalapati <karun256@gmail.com>
Signed-off-by: Amitkumar Karwar <amit.karwar@redpinesignals.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/rsi/rsi_91x_sdio.c

index ebfd29cafbbebf6f9f1a609d55faa596449a5b15..f1ba8ac3783d5c37671c12e13a9d23eac09d57a4 100644 (file)
@@ -1026,17 +1026,26 @@ static void rsi_disconnect(struct sdio_func *pfunction)
                return;
 
        dev = (struct rsi_91x_sdiodev *)adapter->rsi_dev;
+       sdio_claim_host(pfunction);
+       sdio_release_irq(pfunction);
+       sdio_release_host(pfunction);
+       mdelay(10);
 
-       dev->write_fail = 2;
        rsi_mac80211_detach(adapter);
+       mdelay(10);
 
-       sdio_claim_host(pfunction);
-       sdio_release_irq(pfunction);
-       sdio_disable_func(pfunction);
-       rsi_91x_deinit(adapter);
+       /* Reset Chip */
        rsi_reset_chip(adapter);
+
+       /* Resetting to take care of the case, where-in driver is re-loaded */
+       sdio_claim_host(pfunction);
        rsi_reset_card(pfunction);
+       sdio_disable_func(pfunction);
        sdio_release_host(pfunction);
+       dev->write_fail = 2;
+       rsi_91x_deinit(adapter);
+       rsi_dbg(ERR_ZONE, "##### RSI SDIO device disconnected #####\n");
+
 }
 
 #ifdef CONFIG_PM