On 2013-07-24 22:24, H Hartley Sweeten wrote:
Rename the local variable used for the private data pointer to the comedi "norm". Use memset() to initialize the urb transfer_buffer. Set the pwm_cmd_running after submitting the pwm urbs so we don't have to clear it if the submit fails.
Same problem as for AI and AO subdevices in that the URB completion routine may execute before you set pwm_cmd_running.
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 | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 2bfb1b4..7181bc3 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -1538,33 +1538,28 @@ static int usbdux_pwm_period(struct comedi_device *dev, return 0; } -/* is called from insn so there's no need to do all the sanity checks */ static int usbdux_pwm_start(struct comedi_device *dev, struct comedi_subdevice *s) { - int ret, i; - struct usbdux_private *this_usbduxsub = dev->private; + struct usbdux_private *devpriv = dev->private; + int ret; - if (this_usbduxsub->pwm_cmd_running) { - /* already running */ + if (devpriv->pwm_cmd_running) return 0; - } - this_usbduxsub->dux_commands[1] = ((int8_t) this_usbduxsub->pwn_delay); + devpriv->dux_commands[1] = devpriv->pwn_delay; ret = send_dux_commands(dev, SENDPWMON); if (ret < 0) return ret; /* initialise the buffer */ - for (i = 0; i < this_usbduxsub->size_pwm_buf; i++) - ((char *)(this_usbduxsub->urb_pwm->transfer_buffer))[i] = 0; + memset(devpriv->urb_pwm->transfer_buffer, 0, devpriv->size_pwm_buf); - this_usbduxsub->pwm_cmd_running = 1; ret = usbduxsub_submit_pwm_urbs(dev); - if (ret < 0) { - this_usbduxsub->pwm_cmd_running = 0; + if (ret < 0) return ret; - } + devpriv->pwm_cmd_running = 1; + return 0; }
-- -=( Ian Abbott @ MEV Ltd. E-mail: <abbotti@xxxxxxxxx> )=- -=( Tel: +44 (0)161 477 1898 FAX: +44 (0)161 718 3587 )=- _______________________________________________ devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxx http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel