[PATCH v3 09/24] staging: ks7010: fix function return code path

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

 



Function has duplicate code clean up sequences; identical function
call followed by return. This would be better expressed with the use
of a goto statement, as is typical in-tree.

One call site places the clean up code within the 'else' branch of an
multi-way decision. This can be more clearly expressed by inverting
the initial decision conditional and jumping directly to the cleanup
code. Subsequent code indentation can then be reduced, aiding
readability.

Fix function return code execution path. Move clean up code to end of
function with a label. Replace duplicate clean up code within function
with a jump to label. Invert conditional, jump to label if new
conditional evaluates to true, reduce indentation in subsequent code.

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

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 42e96e1..2be1c65 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -206,29 +206,26 @@ static void _ks_wlan_hw_power_save(struct ks_wlan_private *priv)
 	ret = ks7010_sdio_read(priv, INT_PENDING, &rw_data, sizeof(rw_data));
 	if (ret) {
 		DPRINTK(1, " error : INT_PENDING=%02X\n", rw_data);
-		queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
-				   &priv->ks_wlan_hw.rw_wq, 1);
-		return;
+		goto queue_delayed_work;
 	}
+	if (rw_data)
+		goto queue_delayed_work;
 
-	if (!rw_data) {
-		rw_data = GCR_B_DOZE;
-		ret = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data));
-		if (ret) {
-			DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
-			queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
-					   &priv->ks_wlan_hw.rw_wq, 1);
-			return;
-		}
-		DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data);
-		atomic_set(&priv->psstatus.status, PS_SNOOZE);
-		DPRINTK(3, "psstatus.status=PS_SNOOZE\n");
-	} else {
-		queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
-				   &priv->ks_wlan_hw.rw_wq, 1);
+	rw_data = GCR_B_DOZE;
+	ret = ks7010_sdio_write(priv, GCR_B, &rw_data, sizeof(rw_data));
+	if (ret) {
+		DPRINTK(1, " error : GCR_B=%02X\n", rw_data);
+		goto queue_delayed_work;
 	}
+	DPRINTK(4, "PMG SET!! : GCR_B=%02X\n", rw_data);
+	atomic_set(&priv->psstatus.status, PS_SNOOZE);
+	DPRINTK(3, "psstatus.status=PS_SNOOZE\n");
 
 	return;
+
+queue_delayed_work:
+	queue_delayed_work(priv->ks_wlan_hw.ks7010sdio_wq,
+			   &priv->ks_wlan_hw.rw_wq, 1);
 }
 
 int ks_wlan_hw_power_save(struct ks_wlan_private *priv)
-- 
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