[PATCH 7/9] staging: ks7010: Remove level of indentation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Checkpatch emits warning that code is too deeply nested.

Remove one level of nesting by inverting if statement conditional
and using goto to maintain program logic.

Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
---
 drivers/staging/ks7010/ks7010_sdio.c | 151 ++++++++++++++++++-----------------
 1 file changed, 76 insertions(+), 75 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 4842b2d..5a69468 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -544,93 +544,94 @@ 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
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel



[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux