Commit 1c379e94 authored by H Hartley Sweeten's avatar H Hartley Sweeten Committed by Greg Kroah-Hartman

staging: comedi: usbduxsigma: init 'pwm_buf_sz' in usbduxsigma_auto_attach()

Initialize this variable with then_ai_urbs and n_ao_urbs in the
attach. Then usbduxsigma_alloc_usb_buffers() can just check the
variable to determine if the urb needs to be allocated.
Signed-off-by: default avatarH Hartley Sweeten <hsweeten@visionengravers.com>
Reviewed-by: default avatarIan Abbott <abbotti@mev.co.uk>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 315a276d
...@@ -1600,19 +1600,16 @@ static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev) ...@@ -1600,19 +1600,16 @@ static int usbduxsigma_alloc_usb_buffers(struct comedi_device *dev)
urb->interval = 1; /* frames */ urb->interval = 1; /* frames */
} }
if (devpriv->high_speed) { if (devpriv->pwm_buf_sz) {
/* max bulk ep size in high speed */
devpriv->pwm_buf_sz = 512;
urb = usb_alloc_urb(0, GFP_KERNEL); urb = usb_alloc_urb(0, GFP_KERNEL);
if (!urb) if (!urb)
return -ENOMEM; return -ENOMEM;
devpriv->pwm_urb = urb; devpriv->pwm_urb = urb;
urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz, GFP_KERNEL);
urb->transfer_buffer = kzalloc(devpriv->pwm_buf_sz,
GFP_KERNEL);
if (!urb->transfer_buffer) if (!urb->transfer_buffer)
return -ENOMEM; return -ENOMEM;
} else {
devpriv->pwm_urb = NULL;
devpriv->pwm_buf_sz = 0;
} }
return 0; return 0;
...@@ -1687,9 +1684,11 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev, ...@@ -1687,9 +1684,11 @@ static int usbduxsigma_auto_attach(struct comedi_device *dev,
if (devpriv->high_speed) { if (devpriv->high_speed) {
devpriv->n_ai_urbs = NUMOFINBUFFERSHIGH; devpriv->n_ai_urbs = NUMOFINBUFFERSHIGH;
devpriv->n_ao_urbs = NUMOFOUTBUFFERSHIGH; devpriv->n_ao_urbs = NUMOFOUTBUFFERSHIGH;
devpriv->pwm_buf_sz = 512;
} else { } else {
devpriv->n_ai_urbs = NUMOFINBUFFERSFULL; devpriv->n_ai_urbs = NUMOFINBUFFERSFULL;
devpriv->n_ao_urbs = NUMOFOUTBUFFERSFULL; devpriv->n_ao_urbs = NUMOFOUTBUFFERSFULL;
devpriv->pwm_buf_sz = 0;
} }
ret = usbduxsigma_alloc_usb_buffers(dev); ret = usbduxsigma_alloc_usb_buffers(dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment