From: H Hartley Sweeten Date: Tue, 30 Jul 2013 00:43:16 +0000 (-0700) Subject: staging: comedi: usbdux: generalize the usb_submit_urb functions X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=d0b31b8b92fc246bdd2b85bba38a28a8343f4909;p=openwrt%2Fstaging%2Fblogic.git staging: comedi: usbdux: generalize the usb_submit_urb functions Generalize a helper function to replace usbduxsub_submit_{in,out}urbs(). Signed-off-by: H Hartley Sweeten Reviewed-by: Ian Abbott Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/comedi/drivers/usbdux.c b/drivers/staging/comedi/drivers/usbdux.c index 7ff731fd804a..bf6c9ffa93ee 100644 --- a/drivers/staging/comedi/drivers/usbdux.c +++ b/drivers/staging/comedi/drivers/usbdux.c @@ -531,7 +531,9 @@ static void usbduxsub_ao_isoc_irq(struct urb *urb) } } -static int usbduxsub_submit_inurbs(struct comedi_device *dev) +static int usbdux_submit_urbs(struct comedi_device *dev, + struct urb **urbs, int num_urbs, + int input_urb) { struct usb_device *usb = comedi_to_usb_dev(dev); struct usbdux_private *devpriv = dev->private; @@ -540,35 +542,12 @@ static int usbduxsub_submit_inurbs(struct comedi_device *dev) int i; /* Submit all URBs and start the transfer on the bus */ - for (i = 0; i < devpriv->n_ai_urbs; i++) { - urb = devpriv->ai_urbs[i]; - - /* in case of a resubmission after an unlink... */ - urb->interval = devpriv->ai_interval; - urb->context = dev; - urb->dev = usb; - urb->status = 0; - urb->transfer_flags = URB_ISO_ASAP; - - ret = usb_submit_urb(urb, GFP_ATOMIC); - if (ret) - return ret; - } - return 0; -} - -static int usbduxsub_submit_outurbs(struct comedi_device *dev) -{ - struct usb_device *usb = comedi_to_usb_dev(dev); - struct usbdux_private *devpriv = dev->private; - struct urb *urb; - int ret; - int i; - - for (i = 0; i < devpriv->n_ao_urbs; i++) { - urb = devpriv->ao_urbs[i]; + for (i = 0; i < num_urbs; i++) { + urb = urbs[i]; /* in case of a resubmission after an unlink... */ + if (input_urb) + urb->interval = devpriv->ai_interval; urb->context = dev; urb->dev = usb; urb->status = 0; @@ -725,7 +704,8 @@ static int usbdux_ai_inttrig(struct comedi_device *dev, if (!devpriv->ai_cmd_running) { devpriv->ai_cmd_running = 1; - ret = usbduxsub_submit_inurbs(dev); + ret = usbdux_submit_urbs(dev, devpriv->ai_urbs, + devpriv->n_ai_urbs, 1); if (ret < 0) { devpriv->ai_cmd_running = 0; goto ai_trig_exit; @@ -807,7 +787,8 @@ static int usbdux_ai_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ devpriv->ai_cmd_running = 1; - ret = usbduxsub_submit_inurbs(dev); + ret = usbdux_submit_urbs(dev, devpriv->ai_urbs, + devpriv->n_ai_urbs, 1); if (ret < 0) { devpriv->ai_cmd_running = 0; /* fixme: unlink here?? */ @@ -944,7 +925,8 @@ static int usbdux_ao_inttrig(struct comedi_device *dev, if (!devpriv->ao_cmd_running) { devpriv->ao_cmd_running = 1; - ret = usbduxsub_submit_outurbs(dev); + ret = usbdux_submit_urbs(dev, devpriv->ao_urbs, + devpriv->n_ao_urbs, 0); if (ret < 0) { devpriv->ao_cmd_running = 0; goto ao_trig_exit; @@ -1105,7 +1087,8 @@ static int usbdux_ao_cmd(struct comedi_device *dev, struct comedi_subdevice *s) if (cmd->start_src == TRIG_NOW) { /* enable this acquisition operation */ devpriv->ao_cmd_running = 1; - ret = usbduxsub_submit_outurbs(dev); + ret = usbdux_submit_urbs(dev, devpriv->ao_urbs, + devpriv->n_ao_urbs, 0); if (ret < 0) { devpriv->ao_cmd_running = 0; /* fixme: unlink here?? */