summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-05-23 19:49:26 (GMT)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-05-30 11:40:49 (GMT)
commit9319d4ab4424f1e3671ecb6f296558112972daed (patch)
tree01cc33a59cc441efd77080c8d55c7696d7b5dd65 /drivers
parent65989c030bbca96be45ed137f6384dbd46030d10 (diff)
downloadlinux-fsl-qoriq-9319d4ab4424f1e3671ecb6f296558112972daed.tar.xz
staging: comedi: usbduxsigma: push usb (*disconnect) into comedi (*detach)
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@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/staging/comedi/drivers/usbduxsigma.c54
1 files 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);