[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20221210090157.793547-9-mailhol.vincent@wanadoo.fr>
Date: Sat, 10 Dec 2022 18:01:56 +0900
From: Vincent Mailhol <mailhol.vincent@...adoo.fr>
To: Marc Kleine-Budde <mkl@...gutronix.de>, linux-can@...r.kernel.org
Cc: Oliver Neukum <oneukum@...e.com>,
Wolfgang Grandegger <wg@...ndegger.com>,
"David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>,
Frank Jungclaus <frank.jungclaus@....eu>, socketcan@....eu,
Yasushi SHOJI <yashi@...cecubics.com>,
Stefan Mätje <stefan.maetje@....eu>,
Hangyu Hua <hbh25y@...il.com>,
Oliver Hartkopp <socketcan@...tkopp.net>,
Peter Fink <pfink@...ist-es.de>,
Jeroen Hofstee <jhofstee@...tronenergy.com>,
Christoph Möhring <cmoehring@...ist-es.de>,
John Whittington <git@...engineering.co.uk>,
Vasanth Sadhasivan <vasanth.sadhasivan@...sara.com>,
Jimmy Assarsson <extja@...ser.com>,
Anssi Hannula <anssi.hannula@...wise.fi>,
Pavel Skripkin <paskripkin@...il.com>,
Stephane Grosjean <s.grosjean@...k-system.com>,
Wolfram Sang <wsa+renesas@...g-engineering.com>,
"Gustavo A . R . Silva" <gustavoars@...nel.org>,
Julia Lawall <Julia.Lawall@...ia.fr>,
Dongliang Mu <dzm91@...t.edu.cn>,
Sebastian Haas <haas@...-wuensche.com>,
Maximilian Schneider <max@...neidersoft.net>,
Daniel Berglund <db@...ser.com>,
Olivier Sobrie <olivier@...rie.be>,
Remigiusz Kołłątaj
<remigiusz.kollataj@...ica.com>,
Jakob Unterwurzacher <jakob.unterwurzacher@...obroma-systems.com>,
Martin Elshuber <martin.elshuber@...obroma-systems.com>,
Bernd Krumboeck <b.krumboeck@...il.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Alan Stern <stern@...land.harvard.edu>,
linux-usb@...r.kernel.org,
Vincent Mailhol <mailhol.vincent@...adoo.fr>
Subject: [PATCH v2 8/9] can: usb: remove useless check on driver data
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@...adoo.fr>
---
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
Powered by blists - more mailing lists