summaryrefslogtreecommitdiff
path: root/drivers/staging/comedi
diff options
context:
space:
mode:
authorH Hartley Sweeten <hsweeten@visionengravers.com>2013-02-05 17:21:40 -0700
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2013-02-05 18:07:10 -0800
commit78f8fa7f00689f4385c28b1b2be30c83f331c497 (patch)
tree86627d075446cb3dfdd65c7c4585e4f461dfc46e /drivers/staging/comedi
parent49253d542cc0f5f771dc254d248162a2a666649d (diff)
staging: comedi: vmk80xx: factor out usb buffer allocation
Factor the code that allocates the usb buffers out of vmk80xx_usb_probe(). Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com> Cc: Ian Abbott <abbotti@mev.co.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/comedi')
-rw-r--r--drivers/staging/comedi/drivers/vmk80xx.c35
1 files changed, 22 insertions, 13 deletions
diff --git a/drivers/staging/comedi/drivers/vmk80xx.c b/drivers/staging/comedi/drivers/vmk80xx.c
index 26c10a864684..f52d34d1bddf 100644
--- a/drivers/staging/comedi/drivers/vmk80xx.c
+++ b/drivers/staging/comedi/drivers/vmk80xx.c
@@ -1172,6 +1172,25 @@ static int vmk80xx_find_usb_endpoints(struct vmk80xx_private *devpriv,
return 0;
}
+static int vmk80xx_alloc_usb_buffers(struct vmk80xx_private *devpriv)
+{
+ size_t size;
+
+ size = le16_to_cpu(devpriv->ep_rx->wMaxPacketSize);
+ devpriv->usb_rx_buf = kmalloc(size, GFP_KERNEL);
+ if (!devpriv->usb_rx_buf)
+ return -ENOMEM;
+
+ size = le16_to_cpu(devpriv->ep_tx->wMaxPacketSize);
+ devpriv->usb_tx_buf = kmalloc(size, GFP_KERNEL);
+ if (!devpriv->usb_tx_buf) {
+ kfree(devpriv->usb_rx_buf);
+ return -ENOMEM;
+ }
+
+ return 0;
+}
+
static int vmk80xx_attach_common(struct comedi_device *dev,
struct vmk80xx_private *devpriv)
{
@@ -1333,7 +1352,6 @@ static int vmk80xx_usb_probe(struct usb_interface *intf,
{
const struct vmk80xx_board *boardinfo;
struct vmk80xx_private *devpriv;
- size_t size;
int ret;
int i;
@@ -1359,19 +1377,10 @@ static int vmk80xx_usb_probe(struct usb_interface *intf,
return ret;
}
- size = le16_to_cpu(devpriv->ep_rx->wMaxPacketSize);
- devpriv->usb_rx_buf = kmalloc(size, GFP_KERNEL);
- if (!devpriv->usb_rx_buf) {
- mutex_unlock(&glb_mutex);
- return -ENOMEM;
- }
-
- size = le16_to_cpu(devpriv->ep_tx->wMaxPacketSize);
- devpriv->usb_tx_buf = kmalloc(size, GFP_KERNEL);
- if (!devpriv->usb_tx_buf) {
- kfree(devpriv->usb_rx_buf);
+ ret = vmk80xx_alloc_usb_buffers(devpriv);
+ if (ret) {
mutex_unlock(&glb_mutex);
- return -ENOMEM;
+ return ret;
}
devpriv->usb = interface_to_usbdev(intf);