Commit efead44a authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

USB: create usb_init_urb() for those people who like to live dangerously (like...

USB: create usb_init_urb() for those people who like to live dangerously (like the bluetooth stack.)
parent 30a9f6e3
...@@ -13,6 +13,29 @@ ...@@ -13,6 +13,29 @@
#include <linux/usb.h> #include <linux/usb.h>
#include "hcd.h" #include "hcd.h"
/**
* usb_init_urb - initializes a urb so that it can be used by a USB driver
* @urb: pointer to the urb to initialize
*
* Initializes a urb so that the USB subsystem can use it properly.
*
* If a urb is created with a call to usb_alloc_urb() it is not
* necessary to call this function. Only use this if you allocate the
* space for a struct urb on your own. If you call this function, be
* careful when freeing the memory for your urb that it is no longer in
* use by the USB core.
*
* Only use this function if you _really_ understand what you are doing.
*/
void usb_init_urb(struct urb *urb)
{
if (urb) {
memset(urb, 0, sizeof(*urb));
urb->count = (atomic_t)ATOMIC_INIT(1);
spin_lock_init(&urb->lock);
}
}
/** /**
* usb_alloc_urb - creates a new urb for a USB driver to use * usb_alloc_urb - creates a new urb for a USB driver to use
* @iso_packets: number of iso packets for this urb * @iso_packets: number of iso packets for this urb
...@@ -40,11 +63,7 @@ struct urb *usb_alloc_urb(int iso_packets, int mem_flags) ...@@ -40,11 +63,7 @@ struct urb *usb_alloc_urb(int iso_packets, int mem_flags)
err("alloc_urb: kmalloc failed"); err("alloc_urb: kmalloc failed");
return NULL; return NULL;
} }
usb_init_urb(urb);
memset(urb, 0, sizeof(*urb));
urb->count = (atomic_t)ATOMIC_INIT(1);
spin_lock_init(&urb->lock);
return urb; return urb;
} }
...@@ -387,7 +406,7 @@ int usb_unlink_urb(struct urb *urb) ...@@ -387,7 +406,7 @@ int usb_unlink_urb(struct urb *urb)
return -ENODEV; return -ENODEV;
} }
// asynchronous request completion model EXPORT_SYMBOL(usb_init_urb);
EXPORT_SYMBOL(usb_alloc_urb); EXPORT_SYMBOL(usb_alloc_urb);
EXPORT_SYMBOL(usb_free_urb); EXPORT_SYMBOL(usb_free_urb);
EXPORT_SYMBOL(usb_get_urb); EXPORT_SYMBOL(usb_get_urb);
......
...@@ -765,6 +765,7 @@ static inline void usb_fill_int_urb (struct urb *urb, ...@@ -765,6 +765,7 @@ static inline void usb_fill_int_urb (struct urb *urb,
urb->start_frame = -1; urb->start_frame = -1;
} }
extern void usb_init_urb(struct urb *urb);
extern struct urb *usb_alloc_urb(int iso_packets, int mem_flags); extern struct urb *usb_alloc_urb(int iso_packets, int mem_flags);
extern void usb_free_urb(struct urb *urb); extern void usb_free_urb(struct urb *urb);
#define usb_put_urb usb_free_urb #define usb_put_urb usb_free_urb
......
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