[PATCH 16/18] staging: comedi: usbdux: tidy up usbdux_detach()

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

 



Make sure the usb intfdata is always cleared when the device is
detached.

Refactor the code to remove an indent level.

Always unlink the urbs when the device is detached.

Signed-off-by: H Hartley Sweeten <hsweeten@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/usbdux.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 75b2de3..991c425 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1799,20 +1799,21 @@ static void usbdux_detach(struct comedi_device *dev)
 	struct usb_interface *intf = comedi_to_usb_interface(dev);
 	struct usbdux_private *devpriv = dev->private;
 
-	if (devpriv) {
-		down(&devpriv->sem);
+	usb_set_intfdata(intf, NULL);
 
-		usb_set_intfdata(intf, NULL);
+	if (!devpriv)
+		return;
+
+	down(&devpriv->sem);
 
-		/* stop and unlink any submitted urbs */
-		usbdux_pwm_stop(dev, devpriv->pwm_cmd_running);
-		usbdux_ao_stop(dev, devpriv->ao_cmd_running);
-		usbdux_ai_stop(dev, devpriv->ai_cmd_running);
+	/* force unlink all urbs */
+	usbdux_pwm_stop(dev, 1);
+	usbdux_ao_stop(dev, 1);
+	usbdux_ai_stop(dev, 1);
 
-		usbdux_free_usb_buffers(devpriv);
+	usbdux_free_usb_buffers(devpriv);
 
-		up(&devpriv->sem);
-	}
+	up(&devpriv->sem);
 }
 
 static struct comedi_driver usbdux_driver = {
-- 
1.8.3.2

_______________________________________________
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