[PATCH 23/77] staging: comedi: usbduxsigma: push usb (*disconnect) into comedi (*detach)

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

 



The usb_driver (*disconnect) already calls comedi_usb_auto_unconfig(), which
will call the comedi_driver (*detach). Move the other operations in the
(*disconnect) into the (*detach). The comedi_usb_auto_unconfig() can then
be used directly for the (*disconnect).

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

diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c
index 5cd9455..56fc95d 100644
--- a/drivers/staging/comedi/drivers/usbduxsigma.c
+++ b/drivers/staging/comedi/drivers/usbduxsigma.c
@@ -2023,15 +2023,23 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev,
 
 static void usbduxsigma_detach(struct comedi_device *dev)
 {
-	struct usbduxsigma_private *usb = dev->private;
+	struct usbduxsigma_private *devpriv = dev->private;
 
-	if (usb) {
-		down(&usb->sem);
-		dev->private = NULL;
-		usb->attached = 0;
-		usb->comedidev = NULL;
-		up(&usb->sem);
-	}
+	if (!devpriv)
+		return;
+
+	/* stop any running commands */
+	usbdux_ai_stop(devpriv, devpriv->ai_cmd_running);
+	usbdux_ao_stop(devpriv, devpriv->ao_cmd_running);
+
+	down(&start_stop_sem);
+	down(&devpriv->sem);
+	dev->private = NULL;
+	devpriv->attached = 0;
+	devpriv->comedidev = NULL;
+	tidy_up(devpriv);
+	up(&devpriv->sem);
+	up(&start_stop_sem);
 }
 
 static struct comedi_driver usbduxsigma_driver = {
@@ -2107,34 +2115,6 @@ static int usbduxsigma_usb_probe(struct usb_interface *intf,
 	return comedi_usb_auto_config(intf, &usbduxsigma_driver, 0);;
 }
 
-static void usbduxsigma_usb_disconnect(struct usb_interface *intf)
-{
-	struct usbduxsigma_private *usbduxsub_tmp = usb_get_intfdata(intf);
-	struct usb_device *udev = interface_to_usbdev(intf);
-
-	if (!usbduxsub_tmp) {
-		dev_err(&intf->dev,
-			"comedi_: disconnect called with null pointer.\n");
-		return;
-	}
-	if (usbduxsub_tmp->usbdev != udev) {
-		dev_err(&intf->dev, "comedi_: BUG! wrong ptr!\n");
-		return;
-	}
-	if (usbduxsub_tmp->ai_cmd_running)
-		/* we are still running a command */
-		usbdux_ai_stop(usbduxsub_tmp, 1);
-	if (usbduxsub_tmp->ao_cmd_running)
-		/* we are still running a command */
-		usbdux_ao_stop(usbduxsub_tmp, 1);
-	comedi_usb_auto_unconfig(intf);
-	down(&start_stop_sem);
-	down(&usbduxsub_tmp->sem);
-	tidy_up(usbduxsub_tmp);
-	up(&usbduxsub_tmp->sem);
-	up(&start_stop_sem);
-}
-
 static const struct usb_device_id usbduxsigma_usb_table[] = {
 	{ USB_DEVICE(0x13d8, 0x0020) },
 	{ USB_DEVICE(0x13d8, 0x0021) },
@@ -2146,7 +2126,7 @@ MODULE_DEVICE_TABLE(usb, usbduxsigma_usb_table);
 static struct usb_driver usbduxsigma_usb_driver = {
 	.name		= "usbduxsigma",
 	.probe		= usbduxsigma_usb_probe,
-	.disconnect	= usbduxsigma_usb_disconnect,
+	.disconnect	= comedi_usb_auto_unconfig,
 	.id_table	= usbduxsigma_usb_table,
 };
 module_comedi_usb_driver(usbduxsigma_driver, usbduxsigma_usb_driver);
-- 
1.8.1.4

_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/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