Function ks_sdio_interrupt() is deeply nested. One level of indentation
may be removed by inverting an 'if' statement conditional. Body of
statement makes up the bulk of the function. Goto can be used to
return early from function. It is not necessary to alter the function
logic. Once completed, this will open the way for further refactoring.

Invert conditional. Add goto statement to return from function if new
conditional evaluates true. Reduce level of indentation by one. Do not
alter program logic. 

Signed-off-by: Tobin C. Harding <m...@tobin.cc>
---
 drivers/staging/ks7010/ks7010_sdio.c | 157 ++++++++++++++++++-----------------
 1 file changed, 79 insertions(+), 78 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c 
b/drivers/staging/ks7010/ks7010_sdio.c
index 14580cb..cb7dc2e 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -1,4 +1,4 @@
-/*
+r/*
  *   Driver for KeyStream, KS7010 based SDIO cards.
  *
  *   Copyright (C) 2006-2008 KeyStream Corp.
@@ -544,95 +544,96 @@ static void ks_sdio_interrupt(struct sdio_func *func)
        priv = card->priv;
        DPRINTK(4, "\n");
 
-       if (priv->dev_state >= DEVICE_STATE_BOOT) {
+       if (priv->dev_state < DEVICE_STATE_BOOT)
+               goto intr_out;
+
+       retval =
+               ks7010_sdio_read(priv, INT_PENDING, &status,
+                               sizeof(status));
+       if (retval) {
+               DPRINTK(1, "read INT_PENDING Failed!!(%d)\n", retval);
+               goto intr_out;
+       }
+       DPRINTK(4, "INT_PENDING=%02X\n", rw_data);
+
+       /* schedule task for interrupt status */
+       /* bit7 -> Write General Communication B register */
+       /* read (General Communication B register) */
+       /* bit5 -> Write Status Idle */
+       /* bit2 -> Read Status Busy  */
+       if (status & INT_GCR_B
+               || atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
                retval =
-                   ks7010_sdio_read(priv, INT_PENDING, &status,
-                                    sizeof(status));
+                       ks7010_sdio_read(priv, GCR_B, &rw_data,
+                                       sizeof(rw_data));
                if (retval) {
-                       DPRINTK(1, "read INT_PENDING Failed!!(%d)\n", retval);
+                       DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
                        goto intr_out;
                }
-               DPRINTK(4, "INT_PENDING=%02X\n", rw_data);
-
-               /* schedule task for interrupt status */
-               /* bit7 -> Write General Communication B register */
-               /* read (General Communication B register) */
-               /* bit5 -> Write Status Idle */
-               /* bit2 -> Read Status Busy  */
-               if (status & INT_GCR_B
-                   || atomic_read(&priv->psstatus.status) == PS_SNOOZE) {
-                       retval =
-                           ks7010_sdio_read(priv, GCR_B, &rw_data,
-                                            sizeof(rw_data));
-                       if (retval) {
-                               DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
-                               goto intr_out;
-                       }
-                       /* DPRINTK(1, "GCR_B=%02X\n", rw_data); */
-                       if (rw_data == GCR_B_ACTIVE) {
-                               if (atomic_read(&priv->psstatus.status) ==
-                                   PS_SNOOZE) {
-                                       atomic_set(&priv->psstatus.status,
-                                                  PS_WAKEUP);
-                                       priv->wakeup_count = 0;
-                               }
-                               complete(&priv->psstatus.wakeup_wait);
+               /* DPRINTK(1, "GCR_B=%02X\n", rw_data); */
+               if (rw_data == GCR_B_ACTIVE) {
+                       if (atomic_read(&priv->psstatus.status) ==
+                               PS_SNOOZE) {
+                               atomic_set(&priv->psstatus.status,
+                                       PS_WAKEUP);
+                               priv->wakeup_count = 0;
                        }
+                       complete(&priv->psstatus.wakeup_wait);
                }
+       }
 
-               do {
-                       /* read (WriteStatus/ReadDataSize FN1:00_0014) */
-                       retval =
-                           ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data,
-                                            sizeof(rw_data));
-                       if (retval) {
-                               DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n",
-                                       rw_data);
-                               goto intr_out;
-                       }
-                       DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
-                       rsize = rw_data & RSIZE_MASK;
-                       if (rsize) {    /* Read schedule */
-                               ks_wlan_hw_rx((void *)priv,
-                                             (uint16_t)(rsize << 4));
-                       }
-                       if (rw_data & WSTATUS_MASK) {
+       do {
+               /* read (WriteStatus/ReadDataSize FN1:00_0014) */
+               retval =
+                       ks7010_sdio_read(priv, WSTATUS_RSIZE, &rw_data,
+                                       sizeof(rw_data));
+               if (retval) {
+                       DPRINTK(1, " error : WSTATUS_RSIZE=%02X\n",
+                               rw_data);
+                       goto intr_out;
+               }
+               DPRINTK(4, "WSTATUS_RSIZE=%02X\n", rw_data);
+               rsize = rw_data & RSIZE_MASK;
+               if (rsize) {    /* Read schedule */
+                       ks_wlan_hw_rx((void *)priv,
+                               (uint16_t)(rsize << 4));
+               }
+               if (rw_data & WSTATUS_MASK) {
 #if 0
-                               if (status & INT_WRITE_STATUS
-                                   && !cnt_txqbody(priv)) {
-                                       /* dummy write for interrupt clear */
-                                       rw_data = 0;
-                                       retval =
-                                           ks7010_sdio_write(priv, DATA_WINDOW,
-                                                             &rw_data,
-                                                             sizeof(rw_data));
-                                       if (retval) {
-                                               DPRINTK(1,
-                                                       "write DATA_WINDOW 
Failed!!(%d)\n",
-                                                       retval);
-                                       }
-                                       status &= ~INT_WRITE_STATUS;
-                               } else {
+                       if (status & INT_WRITE_STATUS
+                               && !cnt_txqbody(priv)) {
+                               /* dummy write for interrupt clear */
+                               rw_data = 0;
+                               retval =
+                                       ks7010_sdio_write(priv, DATA_WINDOW,
+                                                       &rw_data,
+                                                       sizeof(rw_data));
+                               if (retval) {
+                                       DPRINTK(1,
+                                               "write DATA_WINDOW 
Failed!!(%d)\n",
+                                               retval);
+                               }
+                               status &= ~INT_WRITE_STATUS;
+                       } else {
 #endif
-                                       if (atomic_read(&priv->psstatus.status) 
== PS_SNOOZE) {
-                                               if (cnt_txqbody(priv)) {
-                                                       
ks_wlan_hw_wakeup_request(priv);
-                                                       queue_delayed_work
-                                                           (priv->ks_wlan_hw.
-                                                            ks7010sdio_wq,
-                                                            &priv->ks_wlan_hw.
-                                                            rw_wq, 1);
-                                                       return;
-                                               }
-                                       } else {
-                                               tx_device_task((void *)priv);
+                               if (atomic_read(&priv->psstatus.status) == 
PS_SNOOZE) {
+                                       if (cnt_txqbody(priv)) {
+                                               ks_wlan_hw_wakeup_request(priv);
+                                               queue_delayed_work
+                                                       (priv->ks_wlan_hw.
+                                                               ks7010sdio_wq,
+                                                               
&priv->ks_wlan_hw.
+                                                               rw_wq, 1);
+                                               return;
                                        }
-#if 0
+                               } else {
+                                       tx_device_task((void *)priv);
                                }
-#endif
+#if 0
                        }
-               } while (rsize);
-       }
+#endif
+               }
+       } while (rsize);
 
  intr_out:
        queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
-- 
2.7.4

_______________________________________________
devel mailing list
de...@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

Reply via email to