staging: comedi: usbduxsigma: generalize the ai/ao usb_kill_urb()

Generalize a helper function to replace for() loops in usbduxsigma_{ai,ao}_stop()
that call usb_kill_urb() to unlink all the urbs.

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>
This commit is contained in:
H Hartley Sweeten 2013-07-29 17:43:36 -07:00 committed by Greg Kroah-Hartman
parent d0b31b8b92
commit e0bc079c66
1 changed files with 12 additions and 16 deletions

View File

@ -195,18 +195,20 @@ struct usbduxsigma_private {
struct semaphore sem;
};
static void usbduxsigma_unlink_urbs(struct urb **urbs, int num_urbs)
{
int i;
for (i = 0; i < num_urbs; i++)
usb_kill_urb(urbs[i]);
}
static void usbduxsigma_ai_stop(struct comedi_device *dev, int do_unlink)
{
struct usbduxsigma_private *devpriv = dev->private;
if (do_unlink) {
int i;
for (i = 0; i < devpriv->n_ai_urbs; i++) {
if (devpriv->ai_urbs[i])
usb_kill_urb(devpriv->ai_urbs[i]);
}
}
if (do_unlink && devpriv->ai_urbs)
usbduxsigma_unlink_urbs(devpriv->ai_urbs, devpriv->n_ai_urbs);
devpriv->ai_cmd_running = 0;
}
@ -342,14 +344,8 @@ static void usbduxsigma_ao_stop(struct comedi_device *dev, int do_unlink)
{
struct usbduxsigma_private *devpriv = dev->private;
if (do_unlink) {
int i;
for (i = 0; i < devpriv->n_ao_urbs; i++) {
if (devpriv->ao_urbs[i])
usb_kill_urb(devpriv->ao_urbs[i]);
}
}
if (do_unlink && devpriv->ao_urbs)
usbduxsigma_unlink_urbs(devpriv->ao_urbs, devpriv->n_ao_urbs);
devpriv->ao_cmd_running = 0;
}