[PATCH 06/10] staging: ks7010: return directly on error

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

 



Function uses goto label with no clean up code. In this case we
should just return directly.

Remove goto statement, return directly on error.

Signed-off-by: Tobin C. Harding <me@xxxxxxxx>
---

'/* length check fail */' comment added because preceding line is a
standard function return value check followed by single (un-braced)
statement. Following this with a return makes it look like there is a
bug (missing braces). Adding the comment will save the next (and
subsequent) developers from having to think through this.

 drivers/staging/ks7010/ks7010_sdio.c | 10 ++++------
 drivers/staging/ks7010/ks_wlan_net.c |  7 +++----
 2 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 1d3a15f..3dab700 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -400,7 +400,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
 	if (cnt_rxqbody(priv) >= (RX_DEVICE_BUFF_SIZE - 1)) {
 		/* in case of buffer overflow */
 		DPRINTK(1, "rx buffer overflow\n");
-		goto error_out;
+		return;
 	}
 	rx_buffer = &priv->rx_dev.rx_dev_buff[priv->rx_dev.qtail];
 
@@ -408,7 +408,7 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
 	    ks7010_sdio_read(priv, DATA_WINDOW, &rx_buffer->data[0],
 			     hif_align_size(size));
 	if (retval)
-		goto error_out;
+		return;
 
 	/* length check */
 	if (size > 2046 || size == 0) {
@@ -426,7 +426,8 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
 		if (retval)
 			DPRINTK(1, " error : READ_STATUS=%02X\n", read_status);
 
-		goto error_out;
+		/* length check fail */
+		return;
 	}
 
 	hdr = (struct hostif_hdr *)&rx_buffer->data[0];
@@ -453,9 +454,6 @@ static void ks_wlan_hw_rx(void *dev, uint16_t size)
 
 	/* rx_event_task((void *)priv); */
 	tasklet_schedule(&priv->ks_wlan_hw.rx_bh_task);
-
- error_out:
-	return;
 }
 
 static void ks7010_rw_function(struct work_struct *work)
diff --git a/drivers/staging/ks7010/ks_wlan_net.c b/drivers/staging/ks7010/ks_wlan_net.c
index f18ff56..d96eed6 100644
--- a/drivers/staging/ks7010/ks_wlan_net.c
+++ b/drivers/staging/ks7010/ks_wlan_net.c
@@ -202,7 +202,6 @@ static int ks_wlan_set_freq(struct net_device *dev,
 {
 	struct ks_wlan_private *priv =
 	    (struct ks_wlan_private *)netdev_priv(dev);
-	int rc = -EINPROGRESS;	/* Call commit handler */
 
 	if (priv->sleep_mode == SLP_SLEEP)
 		return -EPERM;
@@ -222,7 +221,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
 	}
 	/* Setting by channel number */
 	if ((fwrq->m > 1000) || (fwrq->e > 0)) {
-		rc = -EOPNOTSUPP;
+		return -EOPNOTSUPP;
 	} else {
 		int channel = fwrq->m;
 		/* We should do a better check than that,
@@ -232,7 +231,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
 			netdev_dbg(dev,
 				   "%s: New channel value of %d is invalid!\n",
 				   dev->name, fwrq->m);
-			rc = -EINVAL;
+			return -EINVAL;
 		} else {
 			/* Yes ! We can set it !!! */
 			priv->reg.channel = (u8)(channel);
@@ -240,7 +239,7 @@ static int ks_wlan_set_freq(struct net_device *dev,
 		}
 	}
 
-	return rc;
+	return -EINPROGRESS;	/* Call commit handler */
 }
 
 static int ks_wlan_get_freq(struct net_device *dev,
-- 
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