From: H Hartley Sweeten Date: Thu, 23 May 2013 19:42:01 +0000 (-0700) Subject: staging: comedi: usbduxsigma: cleanup the (*cancel) functions X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=eac456c82376f6592b2fb8dd6f76d230bf24476e;p=linux-beck.git staging: comedi: usbduxsigma: cleanup the (*cancel) functions The (*cancel) functions can only be called by the comedi core it the (*auto_attach) completed successfully. That function sets the comedi_device 'private' variable before initializing the callbacks so the sanity checks are unnecessary. Remove them. Also, rename the 'this_usbduxsub' local variable to 'devpriv' as this is more common in comedi drivers. Remove the unnecessary comments. Signed-off-by: H Hartley Sweeten Cc: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/usbduxsigma.c b/drivers/staging/comedi/drivers/usbduxsigma.c index c0e2f9e4e5e2..eca29e4d7d35 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -270,25 +270,15 @@ static void usbdux_ai_stop(struct usbduxsub *devpriv, int do_unlink) devpriv->ai_cmd_running = 0; } -/* - * This will cancel a running acquisition operation. - * This is called by comedi but never from inside the driver. - */ static int usbdux_ai_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbduxsub *this_usbduxsub; - - /* force unlink of all urbs */ - this_usbduxsub = dev->private; - if (!this_usbduxsub) - return -EFAULT; + struct usbduxsub *devpriv = dev->private; - /* prevent other CPUs from submitting new commands just now */ - down(&this_usbduxsub->sem); - /* unlink only if the urb really has been submitted */ - usbdux_ai_stop(this_usbduxsub, this_usbduxsub->ai_cmd_running); - up(&this_usbduxsub->sem); + down(&devpriv->sem); + /* unlink only if it is really running */ + usbdux_ai_stop(devpriv, devpriv->ai_cmd_running); + up(&devpriv->sem); return 0; } @@ -456,20 +446,15 @@ static void usbdux_ao_stop(struct usbduxsub *devpriv, int do_unlink) devpriv->ao_cmd_running = 0; } -/* force unlink, is called by comedi */ static int usbdux_ao_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbduxsub *this_usbduxsub = dev->private; + struct usbduxsub *devpriv = dev->private; - if (!this_usbduxsub) - return -EFAULT; - - /* prevent other CPUs from submitting a command just now */ - down(&this_usbduxsub->sem); + down(&devpriv->sem); /* unlink only if it is really running */ - usbdux_ao_stop(this_usbduxsub, this_usbduxsub->ao_cmd_running); - up(&this_usbduxsub->sem); + usbdux_ao_stop(devpriv, devpriv->ao_cmd_running); + up(&devpriv->sem); return 0; } @@ -1627,19 +1612,15 @@ static void usbdux_pwm_stop(struct usbduxsub *devpriv, int do_unlink) devpriv->pwm_cmd_running = 0; } -/* force unlink - is called by comedi */ static int usbdux_pwm_cancel(struct comedi_device *dev, struct comedi_subdevice *s) { - struct usbduxsub *this_usbduxsub = dev->private; - - if (!this_usbduxsub) - return -EFAULT; + struct usbduxsub *devpriv = dev->private; /* unlink only if it is really running */ - usbdux_pwm_stop(this_usbduxsub, this_usbduxsub->pwm_cmd_running); + usbdux_pwm_stop(devpriv, devpriv->pwm_cmd_running); - return send_dux_commands(this_usbduxsub, SENDPWMOFF); + return send_dux_commands(devpriv, SENDPWMOFF); } static void usbduxsub_pwm_irq(struct urb *urb)