X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=include%2Flinux%2Fusb.h;h=cf243917d9c328df1ae01c816bb15b37db50c387;hb=973b9821248435d0a15f0310bc913366a60e338b;hp=608e3a2973401709dbe662e3e5a882eda412dfd2;hpb=86090fcac5e27b630656fe3d963a6b80e26dac44;p=linux-2.6.git diff --git a/include/linux/usb.h b/include/linux/usb.h index 608e3a297..cf243917d 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -14,22 +14,12 @@ #include /* for mdelay() */ #include /* for in_interrupt() */ #include /* for struct list_head */ +#include /* for struct kref */ #include /* for struct device */ #include /* for struct file_operations */ #include /* for struct completion */ #include /* for current && schedule_timeout */ - -static __inline__ void wait_ms(unsigned int ms) -{ - if(!in_interrupt()) { - current->state = TASK_UNINTERRUPTIBLE; - schedule_timeout(1 + ms * HZ / 1000); - } - else - mdelay(ms); -} - struct usb_device; struct usb_driver; @@ -146,12 +136,43 @@ void usb_put_intf(struct usb_interface *intf); /* this maximum is arbitrary */ #define USB_MAXINTERFACES 32 +/** + * struct usb_interface_cache - long-term representation of a device interface + * @num_altsetting: number of altsettings defined. + * @ref: reference counter. + * @altsetting: variable-length array of interface structures, one for + * each alternate setting that may be selected. Each one includes a + * set of endpoint configurations. They will be in no particular order. + * + * These structures persist for the lifetime of a usb_device, unlike + * struct usb_interface (which persists only as long as its configuration + * is installed). The altsetting arrays can be accessed through these + * structures at any time, permitting comparison of configurations and + * providing support for the /proc/bus/usb/devices pseudo-file. + */ +struct usb_interface_cache { + unsigned num_altsetting; /* number of alternate settings */ + struct kref ref; /* reference counter */ + + /* variable-length array of alternate settings for this interface, + * stored in no particular order */ + struct usb_host_interface altsetting[0]; +}; +#define ref_to_usb_interface_cache(r) \ + container_of(r, struct usb_interface_cache, ref) +#define altsetting_to_usb_interface_cache(a) \ + container_of(a, struct usb_interface_cache, altsetting[0]) + /** * struct usb_host_config - representation of a device's configuration * @desc: the device's configuration descriptor. - * @interface: array of usb_interface structures, one for each interface - * in the configuration. The number of interfaces is stored in - * desc.bNumInterfaces. + * @interface: array of pointers to usb_interface structures, one for each + * interface in the configuration. The number of interfaces is stored + * in desc.bNumInterfaces. These pointers are valid only while the + * the configuration is active. + * @intf_cache: array of pointers to usb_interface_cache structures, one + * for each interface in the configuration. These structures exist + * for the entire life of the device. * @extra: pointer to buffer containing all extra descriptors associated * with this configuration (those preceding the first interface * descriptor). @@ -185,6 +206,10 @@ struct usb_host_config { * stored in no particular order */ struct usb_interface *interface[USB_MAXINTERFACES]; + /* Interface information available even when this is not the + * active configuration */ + struct usb_interface_cache *intf_cache[USB_MAXINTERFACES]; + unsigned char *extra; /* Extra descriptors */ int extralen; }; @@ -676,7 +701,7 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *); * URB_NO_SETUP_DMA_MAP indicate which buffers have already been mapped. * URB_NO_SETUP_DMA_MAP is ignored for non-control URBs. * - * Interrupt UBS must provide an interval, saying how often (in milliseconds + * Interrupt URBs must provide an interval, saying how often (in milliseconds * or, for highspeed devices, 125 microsecond units) * to poll for transfers. After the URB has been submitted, the interval * field reflects how the transfer was actually scheduled. @@ -731,8 +756,8 @@ typedef void (*usb_complete_t)(struct urb *, struct pt_regs *); struct urb { /* private, usb core and host controller only fields in the urb */ + struct kref kref; /* reference count of the URB */ spinlock_t lock; /* lock for the URB */ - atomic_t count; /* reference count of the URB */ void *hcpriv; /* private data for host controller */ struct list_head urb_list; /* list pointer to all active urbs */ int bandwidth; /* bandwidth for INT/ISO request */