[v2,8/9] can: usb: remove useless check on driver data
Commit Message
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@wanadoo.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(-)
@@ -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 */
@@ -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 */
@@ -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]);
@@ -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 = {
@@ -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[] = {
@@ -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 = {