[PATCH 11/39] staging: comedi: usbduxfast: Use comedi_usb_auto_unconfig() for (*disconnect)

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

 



The usb_driver (*disconnect) calls comedi_usb_auto_unconfig() then
frees any allocations by calling tidy_up(). comedi_usb_auto_unconfig()
calls the comedi_driver (*detach) function, usbduxfast_detach().

Move the tidy_up() call into usbduxfast_detach() and use the
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@xxxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/usbduxfast.c | 26 ++------------------------
 1 file changed, 2 insertions(+), 24 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbduxfast.c b/drivers/staging/comedi/drivers/usbduxfast.c
index cf99e5b..a83b2b5 100644
--- a/drivers/staging/comedi/drivers/usbduxfast.c
+++ b/drivers/staging/comedi/drivers/usbduxfast.c
@@ -1366,6 +1366,7 @@ static void usbduxfast_detach(struct comedi_device *dev)
 		dev->private = NULL;
 		devpriv->attached = 0;
 		devpriv->comedidev = NULL;
+		tidy_up(devpriv);
 		up(&start_stop_sem);
 		up(&devpriv->sem);
 	}
@@ -1486,29 +1487,6 @@ static int usbduxfast_usb_probe(struct usb_interface *intf,
 	return comedi_usb_auto_config(intf, &usbduxfast_driver, 0);
 }
 
-static void usbduxfast_usb_disconnect(struct usb_interface *intf)
-{
-	struct usbduxfast_private *devpriv = usb_get_intfdata(intf);
-	struct usb_device *usb = interface_to_usbdev(intf);
-
-	if (!devpriv) {
-		dev_err(&intf->dev, "disconnect called with null pointer.\n");
-		return;
-	}
-	if (devpriv->usb != usb) {
-		dev_err(&intf->dev, "BUG! called with wrong ptr!!!\n");
-		return;
-	}
-
-	comedi_usb_auto_unconfig(intf);
-
-	down(&start_stop_sem);
-	down(&devpriv->sem);
-	tidy_up(devpriv);
-	up(&devpriv->sem);
-	up(&start_stop_sem);
-}
-
 static const struct usb_device_id usbduxfast_usb_table[] = {
 	/* { USB_DEVICE(0x4b4, 0x8613) }, testing */
 	{ USB_DEVICE(0x13d8, 0x0010) },	/* real ID */
@@ -1520,7 +1498,7 @@ MODULE_DEVICE_TABLE(usb, usbduxfast_usb_table);
 static struct usb_driver usbduxfast_usb_driver = {
 	.name		= "usbduxfast",
 	.probe		= usbduxfast_usb_probe,
-	.disconnect	= usbduxfast_usb_disconnect,
+	.disconnect	= comedi_usb_auto_unconfig,
 	.id_table	= usbduxfast_usb_table,
 };
 module_comedi_usb_driver(usbduxfast_driver, usbduxfast_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