diff options
author | Hans de Goede <hdegoede@redhat.com> | 2015-05-13 14:42:16 +0200 |
---|---|---|
committer | Simon Glass <sjg@chromium.org> | 2015-05-14 18:49:35 -0600 |
commit | d563e62c3465b8ff2278f1fa493d3936c8217380 (patch) | |
tree | 38fbcf8b25598d55abb48c7f5b8cac1f2a67ec32 /drivers | |
parent | 44dbc33056f731e3704907eb0fd28a01185d333e (diff) | |
download | talos-obmc-uboot-d563e62c3465b8ff2278f1fa493d3936c8217380.tar.gz talos-obmc-uboot-d563e62c3465b8ff2278f1fa493d3936c8217380.zip |
usb: ohci: Add an ohci_alloc_urb() function
Add an ohci_alloc_urb() function, this is a preparation patch for adding
interrupt queue support.
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/usb/host/ohci-hcd.c | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/drivers/usb/host/ohci-hcd.c b/drivers/usb/host/ohci-hcd.c index 5364ced6b6..17f3ac66be 100644 --- a/drivers/usb/host/ohci-hcd.c +++ b/drivers/usb/host/ohci-hcd.c @@ -1505,6 +1505,26 @@ static ohci_dev_t *ohci_get_ohci_dev(ohci_t *ohci, int devnum, int intr) /* common code for handling submit messages - used for all but root hub */ /* accesses. */ +static urb_priv_t *ohci_alloc_urb(struct usb_device *dev, unsigned long pipe, + void *buffer, int transfer_len, int interval) +{ + urb_priv_t *urb; + + urb = calloc(1, sizeof(urb_priv_t)); + if (!urb) { + printf("ohci: Error out of memory allocating urb\n"); + return NULL; + } + + urb->dev = dev; + urb->pipe = pipe; + urb->transfer_buffer = buffer; + urb->transfer_buffer_length = transfer_len; + urb->interval = interval; + + return urb; +} + static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, unsigned long pipe, void *buffer, int transfer_len, struct devrequest *setup, int interval) @@ -1515,14 +1535,9 @@ static int submit_common_msg(ohci_t *ohci, struct usb_device *dev, urb_priv_t *urb; ohci_dev_t *ohci_dev; - urb = malloc(sizeof(urb_priv_t)); - memset(urb, 0, sizeof(urb_priv_t)); - - urb->dev = dev; - urb->pipe = pipe; - urb->transfer_buffer = buffer; - urb->transfer_buffer_length = transfer_len; - urb->interval = interval; + urb = ohci_alloc_urb(dev, pipe, buffer, transfer_len, interval); + if (!urb) + return -ENOMEM; #ifdef DEBUG urb->actual_length = 0; |