From: H Hartley Sweeten Date: Tue, 30 Jul 2013 00:43:36 +0000 (-0700) Subject: staging: comedi: usbduxsigma: generalize the ai/ao usb_kill_urb() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=e0bc079c669a9b6f438f8801da5fc04947323b45;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git 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 Reviewed-by: 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 1af235407eb4..b31e400faf45 100644 --- a/drivers/staging/comedi/drivers/usbduxsigma.c +++ b/drivers/staging/comedi/drivers/usbduxsigma.c @@ -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; }