aboutsummaryrefslogtreecommitdiff
path: root/drivers/staging/comedi/drivers/usbdux.c
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-07-25 16:07:20 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-07-26 15:09:56 -0700
commit96ca37047e774c48cbf5ccf4e6d18e8cf5898dcd (patch)
treeea2c68873f2fe80a499eb46e8f7fcd92304361fd /drivers/staging/comedi/drivers/usbdux.c
parent38f0683502a5c57dd39e4c65ec86cbe8e3975d5b (diff)
staging: comedi: usbdux: fix usbdux_pwm_cancel()
Add the missing down/up of the semaphore to prevent other commands from being issued to the usb device while the pwn is being stopped. Rename the local variable used for the private data pointer to the comedi "norm". Make sure to check that usbdux_pwm_stop() was successful before sending command to the usb device to stop the pwm. Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Reviewed-by: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi/drivers/usbdux.c')
-rw-r--r--drivers/staging/comedi/drivers/usbdux.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 61e9df90e40..14c26e559cb 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1430,17 +1430,25 @@ static int usbdux_pwm_stop(struct comedi_device *dev, int do_unlink)
return ret;
}
-/* force unlink - is called by comedi */
static int usbdux_pwm_cancel(struct comedi_device *dev,
struct comedi_subdevice *s)
{
- struct usbdux_private *this_usbduxsub = dev->private;
- int res = 0;
+ struct usbdux_private *devpriv = dev->private;
+ int ret;
+
+ down(&devpriv->sem);
/* unlink only if it is really running */
- res = usbdux_pwm_stop(dev, this_usbduxsub->pwm_cmd_running);
+ ret = usbdux_pwm_stop(dev, devpriv->pwm_cmd_running);
+ if (ret)
+ goto pwm_cancel_exit;
+
+ ret = send_dux_commands(dev, SENDPWMOFF);
- return send_dux_commands(dev, SENDPWMOFF);
+pwm_cancel_exit:
+ up(&devpriv->sem);
+
+ return ret;
}
static void usbduxsub_pwm_irq(struct urb *urb)