wil6210: fix for unreachable code in wmi_recv_cmd
authorVladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Mon, 16 Jun 2014 16:37:19 +0000 (19:37 +0300)
committerJohn W. Linville <linville@tuxdriver.com>
Thu, 19 Jun 2014 19:49:26 +0000 (15:49 -0400)
As reported by Dan Carpenter <dan.carpenter@oracle.com>:

The patch a715c7ddd65a: "wil6210: improve debug for WMI receive" from
May 29, 2014, leads to the following static checker warning:

        drivers/net/wireless/ath/wil6210/wmi.c:746 wmi_recv_cmd()
        info: ignoring unreachable code.

drivers/net/wireless/ath/wil6210/wmi.c
   739                  spin_unlock_irqrestore(&wil->wmi_ev_lock, flags);
   740                  {
   741                          int q = queue_work(wil->wmi_wq,
   742                                             &wil->wmi_event_worker);
   743                          wil_dbg_wmi(wil, "queue_work -> %d\n", q);
   744                  }
   745          }
   746          if (n > 1)
                ^^^^^^^^^^
We never reach this if statemtent.

   747                  wil_dbg_wmi(wil, "%s -> %d events processed\n", __func__, n);
   748  }

Exit loop with "break", not "return".

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Vladimir Kondratiev <qca_vkondrat@qca.qualcomm.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
drivers/net/wireless/ath/wil6210/wmi.c

index b92a042af2c33c92d06c53ad0662b3099c82fb39..a136dab560e22c94e7c30682d56cbfbb9144745c 100644 (file)
@@ -683,14 +683,12 @@ void wmi_recv_cmd(struct wil6210_priv *wil)
 
        for (n = 0;; n++) {
                u16 len;
+               bool q;
 
                r->head = ioread32(wil->csr + HOST_MBOX +
                                   offsetof(struct wil6210_mbox_ctl, rx.head));
-               if (r->tail == r->head) {
-                       if (n == 0)
-                               wil_dbg_wmi(wil, "No events?\n");
-                       return;
-               }
+               if (r->tail == r->head)
+                       break;
 
                wil_dbg_wmi(wil, "Mbox head %08x tail %08x\n",
                            r->head, r->tail);
@@ -699,14 +697,14 @@ void wmi_recv_cmd(struct wil6210_priv *wil)
                                     sizeof(struct wil6210_mbox_ring_desc));
                if (d_tail.sync == 0) {
                        wil_err(wil, "Mbox evt not owned by FW?\n");
-                       return;
+                       break;
                }
 
                /* read cmd header from descriptor */
                if (0 != wmi_read_hdr(wil, d_tail.addr, &hdr)) {
                        wil_err(wil, "Mbox evt at 0x%08x?\n",
                                le32_to_cpu(d_tail.addr));
-                       return;
+                       break;
                }
                len = le16_to_cpu(hdr.len);
                wil_dbg_wmi(wil, "Mbox evt %04x %04x %04x %02x\n",
@@ -720,7 +718,7 @@ void wmi_recv_cmd(struct wil6210_priv *wil)
                                             event.wmi) + len, 4),
                              GFP_KERNEL);
                if (!evt)
-                       return;
+                       break;
 
                evt->event.hdr = hdr;
                cmd = (void *)&evt->event.wmi;
@@ -752,14 +750,11 @@ void wmi_recv_cmd(struct wil6210_priv *wil)
                spin_lock_irqsave(&wil->wmi_ev_lock, flags);
                list_add_tail(&evt->list, &wil->pending_wmi_ev);
                spin_unlock_irqrestore(&wil->wmi_ev_lock, flags);
-               {
-                       int q = queue_work(wil->wmi_wq,
-                                          &wil->wmi_event_worker);
-                       wil_dbg_wmi(wil, "queue_work -> %d\n", q);
-               }
+               q = queue_work(wil->wmi_wq, &wil->wmi_event_worker);
+               wil_dbg_wmi(wil, "queue_work -> %d\n", q);
        }
-       if (n > 1)
-               wil_dbg_wmi(wil, "%s -> %d events processed\n", __func__, n);
+       /* normally, 1 event per IRQ should be processed */
+       wil_dbg_wmi(wil, "%s -> %d events queued\n", __func__, n);
 }
 
 int wmi_call(struct wil6210_priv *wil, u16 cmdid, void *buf, u16 len,