[PATCH v2 8/9] can: usb: remove useless check on driver data

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

 



Many of the can usb drivers checks in their usb_driver::disconnect()
whether the driver data is NULL or not. This check only makes sense if
the disconnect function can be called more than one time. This is not
the case for can usb drivers.

Remove all checks toward drivers priv data in disconnect().

Signed-off-by: Vincent Mailhol <mailhol.vincent@xxxxxxxxxx>
---
 drivers/net/can/usb/ems_usb.c                    | 14 ++++++--------
 drivers/net/can/usb/esd_usb.c                    | 16 +++++++---------
 drivers/net/can/usb/gs_usb.c                     |  5 -----
 drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c |  7 +------
 drivers/net/can/usb/ucan.c                       |  6 ++----
 drivers/net/can/usb/usb_8dev.c                   | 11 ++++-------
 6 files changed, 20 insertions(+), 39 deletions(-)

diff --git a/drivers/net/can/usb/ems_usb.c b/drivers/net/can/usb/ems_usb.c
index c64cb40ac8de..8bd555eb741f 100644
--- a/drivers/net/can/usb/ems_usb.c
+++ b/drivers/net/can/usb/ems_usb.c
@@ -1062,18 +1062,16 @@ static void ems_usb_disconnect(struct usb_interface *intf)
 {
 	struct ems_usb *dev = usb_get_intfdata(intf);
 
-	if (dev) {
-		unregister_netdev(dev->netdev);
+	unregister_netdev(dev->netdev);
 
-		unlink_all_urbs(dev);
+	unlink_all_urbs(dev);
 
-		usb_free_urb(dev->intr_urb);
+	usb_free_urb(dev->intr_urb);
 
-		kfree(dev->intr_in_buffer);
-		kfree(dev->tx_msg_buffer);
+	kfree(dev->intr_in_buffer);
+	kfree(dev->tx_msg_buffer);
 
-		free_candev(dev->netdev);
-	}
+	free_candev(dev->netdev);
 }
 
 /* usb specific object needed to register this driver with the usb subsystem */
diff --git a/drivers/net/can/usb/esd_usb.c b/drivers/net/can/usb/esd_usb.c
index f3006c6dc5d6..775ab704a295 100644
--- a/drivers/net/can/usb/esd_usb.c
+++ b/drivers/net/can/usb/esd_usb.c
@@ -1127,17 +1127,15 @@ static void esd_usb_disconnect(struct usb_interface *intf)
 	device_remove_file(&intf->dev, &dev_attr_hardware);
 	device_remove_file(&intf->dev, &dev_attr_nets);
 
-	if (dev) {
-		for (i = 0; i < dev->net_count; i++) {
-			if (dev->nets[i]) {
-				netdev = dev->nets[i]->netdev;
-				unregister_netdev(netdev);
-				free_candev(netdev);
-			}
+	for (i = 0; i < dev->net_count; i++) {
+		if (dev->nets[i]) {
+			netdev = dev->nets[i]->netdev;
+			unregister_netdev(netdev);
+			free_candev(netdev);
 		}
-		unlink_all_urbs(dev);
-		kfree(dev);
 	}
+	unlink_all_urbs(dev);
+	kfree(dev);
 }
 
 /* usb specific object needed to register this driver with the usb subsystem */
diff --git a/drivers/net/can/usb/gs_usb.c b/drivers/net/can/usb/gs_usb.c
index 97b1da8fd19f..40190816e313 100644
--- a/drivers/net/can/usb/gs_usb.c
+++ b/drivers/net/can/usb/gs_usb.c
@@ -1458,11 +1458,6 @@ static void gs_usb_disconnect(struct usb_interface *intf)
 	struct gs_usb *dev = usb_get_intfdata(intf);
 	unsigned int i;
 
-	if (!dev) {
-		dev_err(&intf->dev, "Disconnect (nodata)\n");
-		return;
-	}
-
 	for (i = 0; i < GS_MAX_INTF; i++)
 		if (dev->canch[i])
 			gs_destroy_candev(dev->canch[i]);
diff --git a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
index dad916b3288e..9e83b61db96b 100644
--- a/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
+++ b/drivers/net/can/usb/kvaser_usb/kvaser_usb_core.c
@@ -979,12 +979,7 @@ static int kvaser_usb_probe(struct usb_interface *intf,
 
 static void kvaser_usb_disconnect(struct usb_interface *intf)
 {
-	struct kvaser_usb *dev = usb_get_intfdata(intf);
-
-	if (!dev)
-		return;
-
-	kvaser_usb_remove_interfaces(dev);
+	kvaser_usb_remove_interfaces(usb_get_intfdata(intf));
 }
 
 static struct usb_driver kvaser_usb_driver = {
diff --git a/drivers/net/can/usb/ucan.c b/drivers/net/can/usb/ucan.c
index 429b3519ee7f..205941122f9e 100644
--- a/drivers/net/can/usb/ucan.c
+++ b/drivers/net/can/usb/ucan.c
@@ -1579,10 +1579,8 @@ static void ucan_disconnect(struct usb_interface *intf)
 {
 	struct ucan_priv *up = usb_get_intfdata(intf);
 
-	if (up) {
-		unregister_candev(up->netdev);
-		free_candev(up->netdev);
-	}
+	unregister_candev(up->netdev);
+	free_candev(up->netdev);
 }
 
 static struct usb_device_id ucan_table[] = {
diff --git a/drivers/net/can/usb/usb_8dev.c b/drivers/net/can/usb/usb_8dev.c
index ae618809fc05..4d80049ebff7 100644
--- a/drivers/net/can/usb/usb_8dev.c
+++ b/drivers/net/can/usb/usb_8dev.c
@@ -990,14 +990,11 @@ static void usb_8dev_disconnect(struct usb_interface *intf)
 {
 	struct usb_8dev_priv *priv = usb_get_intfdata(intf);
 
-	if (priv) {
-		netdev_info(priv->netdev, "device disconnected\n");
-
-		unregister_netdev(priv->netdev);
-		unlink_all_urbs(priv);
-		free_candev(priv->netdev);
-	}
+	netdev_info(priv->netdev, "device disconnected\n");
 
+	unregister_netdev(priv->netdev);
+	unlink_all_urbs(priv);
+	free_candev(priv->netdev);
 }
 
 static struct usb_driver usb_8dev_driver = {
-- 
2.37.4




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux