[PATCH 05/53] staging: comedi: usbdux: push usb (*disconnect) into comedi (*detach)

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

 



The usb_driver (*disconnect) calls comedi_usb_auto_unconfig() which will
call the comedi_driver (*detach). Just move all the disconnect/detach
into the comedi_driver and use comedi_usb_auto_unconfig() directly for
the (*disconnect).

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

diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 892ecb5..204dfbb 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -2384,15 +2384,18 @@ static int usbdux_auto_attach(struct comedi_device *dev,
 
 static void usbdux_detach(struct comedi_device *dev)
 {
-	struct usbdux_private *usb = dev->private;
+	struct usbdux_private *devpriv = dev->private;
 
-	if (usb) {
-		down(&usb->sem);
+	down(&start_stop_sem);
+	if (devpriv) {
+		down(&devpriv->sem);
+		tidy_up(devpriv);
 		dev->private = NULL;
-		usb->attached = 0;
-		usb->comedidev = NULL;
-		up(&usb->sem);
+		devpriv->attached = 0;
+		devpriv->comedidev = NULL;
+		up(&devpriv->sem);
 	}
+	up(&start_stop_sem);
 }
 
 static struct comedi_driver usbdux_driver = {
@@ -2471,29 +2474,6 @@ static int usbdux_usb_probe(struct usb_interface *uinterf,
 	return comedi_usb_auto_config(uinterf, &usbdux_driver, 0);
 }
 
-static void usbdux_usb_disconnect(struct usb_interface *intf)
-{
-	struct usbdux_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! called with wrong ptr!!!\n");
-		return;
-	}
-	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);
-	dev_dbg(&intf->dev, "comedi_: disconnected from the usb\n");
-}
-
 static const struct usb_device_id usbdux_usb_table[] = {
 	{ USB_DEVICE(0x13d8, 0x0001) },
 	{ USB_DEVICE(0x13d8, 0x0002) },
@@ -2505,7 +2485,7 @@ MODULE_DEVICE_TABLE(usb, usbdux_usb_table);
 static struct usb_driver usbdux_usb_driver = {
 	.name		= "usbdux",
 	.probe		= usbdux_usb_probe,
-	.disconnect	= usbdux_usb_disconnect,
+	.disconnect	= comedi_usb_auto_unconfig,
 	.id_table	= usbdux_usb_table,
 };
 module_comedi_usb_driver(usbdux_driver, usbdux_usb_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