Skip to content

Commit

Permalink
staging: comedi: usbdux: tidy up usbdux_ao_inttrig()
Browse files Browse the repository at this point in the history
Rename the local variable used for the private data pointer to the
comedi "norm".

Remove the unnecessary sanity check of the private data pointer. This
function can only be called is the private data was allocated during
the attach.

Tidy up the exit path using goto to ensure that the semaphore is
released.

Return -EBUSY instead if an ao command is already running.

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>
  • Loading branch information
H Hartley Sweeten authored and Greg Kroah-Hartman committed Jul 26, 2013
1 parent 37c1d1e commit f994282
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions drivers/staging/comedi/drivers/usbdux.c
Original file line number Diff line number Diff line change
Expand Up @@ -1074,31 +1074,32 @@ static int usbdux_ao_insn_write(struct comedi_device *dev,
}

static int usbdux_ao_inttrig(struct comedi_device *dev,
struct comedi_subdevice *s, unsigned int trignum)
struct comedi_subdevice *s,
unsigned int trignum)
{
int ret;
struct usbdux_private *this_usbduxsub = dev->private;
struct usbdux_private *devpriv = dev->private;
int ret = -EINVAL;

if (!this_usbduxsub)
return -EFAULT;
down(&devpriv->sem);

down(&this_usbduxsub->sem);
if (trignum != 0) {
up(&this_usbduxsub->sem);
return -EINVAL;
}
if (!(this_usbduxsub->ao_cmd_running)) {
this_usbduxsub->ao_cmd_running = 1;
if (trignum != 0)
goto ao_trig_exit;

if (!devpriv->ao_cmd_running) {
devpriv->ao_cmd_running = 1;
ret = usbduxsub_submit_outurbs(dev);
if (ret < 0) {
this_usbduxsub->ao_cmd_running = 0;
up(&this_usbduxsub->sem);
return ret;
devpriv->ao_cmd_running = 0;
goto ao_trig_exit;
}
s->async->inttrig = NULL;
} else {
ret = -EBUSY;
}
up(&this_usbduxsub->sem);
return 1;

ao_trig_exit:
up(&devpriv->sem);
return ret;
}

static int usbdux_ao_cmdtest(struct comedi_device *dev,
Expand Down

0 comments on commit f994282

Please sign in to comment.