[PATCH 46/53] staging: comedi: usbdux: fix usbdux_pwm_cancel()

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

 



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@xxxxxxxxxxxxxxxxxxx>
Cc: Ian Abbott <abbotti@xxxxxxxxx>
Cc: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxx>
---
 drivers/staging/comedi/drivers/usbdux.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c
index 5348db7..2bfb1b4 100644
--- a/drivers/staging/comedi/drivers/usbdux.c
+++ b/drivers/staging/comedi/drivers/usbdux.c
@@ -1426,17 +1426,23 @@ 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)
+		return ret;
 
-	return send_dux_commands(dev, SENDPWMOFF);
+	ret = send_dux_commands(dev, SENDPWMOFF);
+	up(&devpriv->sem);
+
+	return ret;
 }
 
 static void usbduxsub_pwm_irq(struct urb *urb)
-- 
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