wil6210: check error in wil_target_reset()
authorVladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Wed, 6 Aug 2014 07:31:52 +0000 (10:31 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Mon, 25 Aug 2014 20:17:32 +0000 (16:17 -0400)
When resetting target in wil_target_reset(), error may occur.
Indicate error via error code. In case of error, don't attempt to further
interact with card, specifically don't attempt firmware download or
interrupts enabling.

Move wil_rx_fini() to be always executed to prevent memory leak.

Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/wil6210/main.c

index dc220537de99220d1756da72e4500909805b1679..5a9934291daba2d2edeefeffb8432a9d6bcdae45 100644 (file)
@@ -309,7 +309,7 @@ void wil_priv_deinit(struct wil6210_priv *wil)
        destroy_workqueue(wil->wmi_wq);
 }
 
-static void wil_target_reset(struct wil6210_priv *wil)
+static int wil_target_reset(struct wil6210_priv *wil)
 {
        int delay = 0;
        u32 hw_state;
@@ -395,7 +395,7 @@ static void wil_target_reset(struct wil6210_priv *wil)
                if (delay++ > 100) {
                        wil_err(wil, "Reset not completed, hw_state 0x%08x\n",
                                hw_state);
-                       return;
+                       return -ETIME;
                }
        } while (hw_state != HW_MACHINE_BOOT_DONE);
 
@@ -407,6 +407,7 @@ static void wil_target_reset(struct wil6210_priv *wil)
        wmb(); /* order is important here */
 
        wil_dbg_misc(wil, "Reset completed in %d ms\n", delay);
+       return 0;
 
 #undef R
 #undef W
@@ -471,10 +472,11 @@ int wil_reset(struct wil6210_priv *wil)
        flush_workqueue(wil->wmi_wq_conn);
        flush_workqueue(wil->wmi_wq);
 
-       /* TODO: put MAC in reset */
-       wil_target_reset(wil);
-
+       rc = wil_target_reset(wil);
        wil_rx_fini(wil);
+       if (rc)
+               return rc;
+
 
        /* init after reset */
        wil->pending_connect_cid = -1;