[PATCH 7/9] staging: ks7010: bail out when registering netdevice fails

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

 



There is no need to continue then. Also, this enables us to remove an
ugly static variable.

Signed-off-by: Wolfram Sang <wsa@xxxxxxxxxxxxx>
---
 drivers/staging/ks7010/ks7010_sdio.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/drivers/staging/ks7010/ks7010_sdio.c b/drivers/staging/ks7010/ks7010_sdio.c
index 16b9d76478b172..c3035b80dac7cd 100644
--- a/drivers/staging/ks7010/ks7010_sdio.c
+++ b/drivers/staging/ks7010/ks7010_sdio.c
@@ -25,8 +25,6 @@
 #define KS7010_IO_BLOCK_SIZE 512
 #define KS7010_MAX_CLOCK 25000000
 
-static int reg_net = 0;
-
 static const struct sdio_device_id ks7010_sdio_ids[] = {
 	{SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_A, SDIO_DEVICE_ID_KS_7010)},
 	{SDIO_DEVICE(SDIO_VENDOR_ID_KS_CODE_B, SDIO_DEVICE_ID_KS_7010)},
@@ -936,8 +934,6 @@ static void ks7010_card_init(struct ks_wlan_private *priv)
 	if (priv->dev_state >= DEVICE_STATE_PREINIT) {
 		DPRINTK(1, "DEVICE READY!!\n");
 		priv->dev_state = DEVICE_STATE_READY;
-		reg_net = register_netdev(priv->net_dev);
-		DPRINTK(3, "register_netdev=%d\n", reg_net);
 	} else {
 		DPRINTK(1, "dev_state=%d\n", priv->dev_state);
 	}
@@ -1115,6 +1111,10 @@ static int ks7010_sdio_probe(struct sdio_func *func,
 	INIT_DELAYED_WORK(&priv->ks_wlan_hw.rw_wq, ks7010_rw_function);
 	ks7010_card_init(priv);
 
+	ret = register_netdev(priv->net_dev);
+	if (ret)
+		goto error_free_read_buf;
+
 	return 0;
 
  error_free_read_buf:
@@ -1196,9 +1196,7 @@ static void ks7010_sdio_remove(struct sdio_func *func)
 		hostif_exit(priv);
 		DPRINTK(1, "hostif_exit\n");
 
-		if (!reg_net)
-			unregister_netdev(netdev);
-		DPRINTK(1, "unregister_netdev\n");
+		unregister_netdev(netdev);
 
 		trx_device_exit(priv);
 		if (priv->ks_wlan_hw.read_buf) {
-- 
2.8.1

_______________________________________________
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