[PATCH] USB: update urb documentation

On Wed, May 04, 2005 at 01:37:30PM -0700, David Brownell wrote:
> On Wednesday 04 May 2005 12:19 pm, Roman Kagan wrote:
> > struct urb {
> > /* private, usb core and host controller only fields in the urb */
> > ...
> > struct list_head urb_list; /* list pointer to all active urbs */
> > ...
> > };
> >
> > Is it safe to use it for driver's purposes when the driver owns the urb,
> > that is, starting from the completion routine until the urb is submitted
> > with usb_submit_urb()?
>
> Right now, it should be.

Great! FWIW I've briefly tested a modified version of usbatm using
the list head in struct urb instead of creating a wrapper struct, and I
haven't seen any failures yet. So I tend to believe that your "should
be" actually means "is" :)

> > If it is, can it be guaranteed in future, e.g.
> > by moving the list head into the public section of struct urb?
>
> In fact I'm not sure why it ever got called "private" to usbcore/hcds.
> I thought the idea was that it should be like urb->status, reserved for
> whoever controls the URB.

OK then how about the following (essentially documentation) patch?

Signed-off-by: Roman Kagan <rkagan@mail.ru>
Acked-by: David Brownell <david-b@pacbell.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by Roman Kagan and committed by Greg KH 719df469 1724757e

+5 -1
+5 -1
include/linux/usb.h
··· 796 * of the iso_frame_desc array, and the number of errors is reported in 797 * error_count. Completion callbacks for ISO transfers will normally 798 * (re)submit URBs to ensure a constant transfer rate. 799 */ 800 struct urb 801 { ··· 807 struct kref kref; /* reference count of the URB */ 808 spinlock_t lock; /* lock for the URB */ 809 void *hcpriv; /* private data for host controller */ 810 - struct list_head urb_list; /* list pointer to all active urbs */ 811 int bandwidth; /* bandwidth for INT/ISO request */ 812 atomic_t use_count; /* concurrent submissions counter */ 813 u8 reject; /* submissions will fail */ 814 815 /* public, documented fields in the urb that can be used by drivers */ 816 struct usb_device *dev; /* (in) pointer to associated device */ 817 unsigned int pipe; /* (in) pipe information */ 818 int status; /* (return) non-ISO status */
··· 796 * of the iso_frame_desc array, and the number of errors is reported in 797 * error_count. Completion callbacks for ISO transfers will normally 798 * (re)submit URBs to ensure a constant transfer rate. 799 + * 800 + * Note that even fields marked "public" should not be touched by the driver 801 + * when the urb is owned by the hcd, that is, since the call to 802 + * usb_submit_urb() till the entry into the completion routine. 803 */ 804 struct urb 805 { ··· 803 struct kref kref; /* reference count of the URB */ 804 spinlock_t lock; /* lock for the URB */ 805 void *hcpriv; /* private data for host controller */ 806 int bandwidth; /* bandwidth for INT/ISO request */ 807 atomic_t use_count; /* concurrent submissions counter */ 808 u8 reject; /* submissions will fail */ 809 810 /* public, documented fields in the urb that can be used by drivers */ 811 + struct list_head urb_list; /* list head for use by the urb owner */ 812 struct usb_device *dev; /* (in) pointer to associated device */ 813 unsigned int pipe; /* (in) pipe information */ 814 int status; /* (return) non-ISO status */