aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/usb.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/usb.h')
-rw-r--r--include/linux/usb.h132
1 files changed, 86 insertions, 46 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 465ff4585ca5..c500d6b5a16d 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -137,7 +137,8 @@ struct usb_interface {
137 * active alternate setting */ 137 * active alternate setting */
138 unsigned num_altsetting; /* number of alternate settings */ 138 unsigned num_altsetting; /* number of alternate settings */
139 139
140 int minor; /* minor number this interface is bound to */ 140 int minor; /* minor number this interface is
141 * bound to */
141 enum usb_interface_condition condition; /* state of binding */ 142 enum usb_interface_condition condition; /* state of binding */
142 struct device dev; /* interface specific device info */ 143 struct device dev; /* interface specific device info */
143 struct class_device *class_dev; 144 struct class_device *class_dev;
@@ -249,7 +250,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
249 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\ 250 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\
250 type,(void**)ptr) 251 type,(void**)ptr)
251 252
252/* -------------------------------------------------------------------------- */ 253/* ----------------------------------------------------------------------- */
253 254
254struct usb_operations; 255struct usb_operations;
255 256
@@ -269,7 +270,8 @@ struct usb_bus {
269 unsigned is_b_host:1; /* true during some HNP roleswitches */ 270 unsigned is_b_host:1; /* true during some HNP roleswitches */
270 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */ 271 unsigned b_hnp_enable:1; /* OTG: did A-Host enable HNP? */
271 272
272 int devnum_next; /* Next open device number in round-robin allocation */ 273 int devnum_next; /* Next open device number in
274 * round-robin allocation */
273 275
274 struct usb_devmap devmap; /* device address allocation map */ 276 struct usb_devmap devmap; /* device address allocation map */
275 struct usb_operations *op; /* Operations (specific to the HC) */ 277 struct usb_operations *op; /* Operations (specific to the HC) */
@@ -290,15 +292,16 @@ struct usb_bus {
290 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ 292 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
291 293
292 struct class_device *class_dev; /* class device for this bus */ 294 struct class_device *class_dev; /* class device for this bus */
293 struct kref kref; /* handles reference counting this bus */ 295 struct kref kref; /* reference counting for this bus */
294 void (*release)(struct usb_bus *bus); /* function to destroy this bus's memory */ 296 void (*release)(struct usb_bus *bus);
297
295#if defined(CONFIG_USB_MON) 298#if defined(CONFIG_USB_MON)
296 struct mon_bus *mon_bus; /* non-null when associated */ 299 struct mon_bus *mon_bus; /* non-null when associated */
297 int monitored; /* non-zero when monitored */ 300 int monitored; /* non-zero when monitored */
298#endif 301#endif
299}; 302};
300 303
301/* -------------------------------------------------------------------------- */ 304/* ----------------------------------------------------------------------- */
302 305
303/* This is arbitrary. 306/* This is arbitrary.
304 * From USB 2.0 spec Table 11-13, offset 7, a hub can 307 * From USB 2.0 spec Table 11-13, offset 7, a hub can
@@ -327,7 +330,8 @@ struct usb_device {
327 330
328 struct semaphore serialize; 331 struct semaphore serialize;
329 332
330 unsigned int toggle[2]; /* one bit for each endpoint ([0] = IN, [1] = OUT) */ 333 unsigned int toggle[2]; /* one bit for each endpoint
334 * ([0] = IN, [1] = OUT) */
331 335
332 struct usb_device *parent; /* our hub, unless we're the root */ 336 struct usb_device *parent; /* our hub, unless we're the root */
333 struct usb_bus *bus; /* Bus we're part of */ 337 struct usb_bus *bus; /* Bus we're part of */
@@ -344,7 +348,7 @@ struct usb_device {
344 348
345 char **rawdescriptors; /* Raw descriptors for each config */ 349 char **rawdescriptors; /* Raw descriptors for each config */
346 350
347 int have_langid; /* whether string_langid is valid yet */ 351 int have_langid; /* whether string_langid is valid */
348 int string_langid; /* language ID for strings */ 352 int string_langid; /* language ID for strings */
349 353
350 char *product; 354 char *product;
@@ -441,22 +445,31 @@ extern struct usb_host_interface *usb_altnum_to_altsetting(
441 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are 445 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are
442 * high speed, and a different one if they are full or low speed. 446 * high speed, and a different one if they are full or low speed.
443 */ 447 */
444static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size) 448static inline int usb_make_path (struct usb_device *dev, char *buf,
449 size_t size)
445{ 450{
446 int actual; 451 int actual;
447 actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, dev->devpath); 452 actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name,
453 dev->devpath);
448 return (actual >= (int)size) ? -1 : actual; 454 return (actual >= (int)size) ? -1 : actual;
449} 455}
450 456
451/*-------------------------------------------------------------------------*/ 457/*-------------------------------------------------------------------------*/
452 458
453#define USB_DEVICE_ID_MATCH_DEVICE (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT) 459#define USB_DEVICE_ID_MATCH_DEVICE \
454#define USB_DEVICE_ID_MATCH_DEV_RANGE (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI) 460 (USB_DEVICE_ID_MATCH_VENDOR | USB_DEVICE_ID_MATCH_PRODUCT)
455#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE) 461#define USB_DEVICE_ID_MATCH_DEV_RANGE \
462 (USB_DEVICE_ID_MATCH_DEV_LO | USB_DEVICE_ID_MATCH_DEV_HI)
463#define USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION \
464 (USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_DEV_RANGE)
456#define USB_DEVICE_ID_MATCH_DEV_INFO \ 465#define USB_DEVICE_ID_MATCH_DEV_INFO \
457 (USB_DEVICE_ID_MATCH_DEV_CLASS | USB_DEVICE_ID_MATCH_DEV_SUBCLASS | USB_DEVICE_ID_MATCH_DEV_PROTOCOL) 466 (USB_DEVICE_ID_MATCH_DEV_CLASS | \
467 USB_DEVICE_ID_MATCH_DEV_SUBCLASS | \
468 USB_DEVICE_ID_MATCH_DEV_PROTOCOL)
458#define USB_DEVICE_ID_MATCH_INT_INFO \ 469#define USB_DEVICE_ID_MATCH_INT_INFO \
459 (USB_DEVICE_ID_MATCH_INT_CLASS | USB_DEVICE_ID_MATCH_INT_SUBCLASS | USB_DEVICE_ID_MATCH_INT_PROTOCOL) 470 (USB_DEVICE_ID_MATCH_INT_CLASS | \
471 USB_DEVICE_ID_MATCH_INT_SUBCLASS | \
472 USB_DEVICE_ID_MATCH_INT_PROTOCOL)
460 473
461/** 474/**
462 * USB_DEVICE - macro used to describe a specific usb device 475 * USB_DEVICE - macro used to describe a specific usb device
@@ -467,9 +480,11 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
467 * specific device. 480 * specific device.
468 */ 481 */
469#define USB_DEVICE(vend,prod) \ 482#define USB_DEVICE(vend,prod) \
470 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), .idProduct = (prod) 483 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \
484 .idProduct = (prod)
471/** 485/**
472 * USB_DEVICE_VER - macro used to describe a specific usb device with a version range 486 * USB_DEVICE_VER - macro used to describe a specific usb device with a
487 * version range
473 * @vend: the 16 bit USB Vendor ID 488 * @vend: the 16 bit USB Vendor ID
474 * @prod: the 16 bit USB Product ID 489 * @prod: the 16 bit USB Product ID
475 * @lo: the bcdDevice_lo value 490 * @lo: the bcdDevice_lo value
@@ -479,7 +494,9 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
479 * specific device, with a version range. 494 * specific device, with a version range.
480 */ 495 */
481#define USB_DEVICE_VER(vend,prod,lo,hi) \ 496#define USB_DEVICE_VER(vend,prod,lo,hi) \
482 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, .idVendor = (vend), .idProduct = (prod), .bcdDevice_lo = (lo), .bcdDevice_hi = (hi) 497 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \
498 .idVendor = (vend), .idProduct = (prod), \
499 .bcdDevice_lo = (lo), .bcdDevice_hi = (hi)
483 500
484/** 501/**
485 * USB_DEVICE_INFO - macro used to describe a class of usb devices 502 * USB_DEVICE_INFO - macro used to describe a class of usb devices
@@ -491,7 +508,8 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
491 * specific class of devices. 508 * specific class of devices.
492 */ 509 */
493#define USB_DEVICE_INFO(cl,sc,pr) \ 510#define USB_DEVICE_INFO(cl,sc,pr) \
494 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), .bDeviceSubClass = (sc), .bDeviceProtocol = (pr) 511 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), \
512 .bDeviceSubClass = (sc), .bDeviceProtocol = (pr)
495 513
496/** 514/**
497 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 515 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces
@@ -503,9 +521,10 @@ static inline int usb_make_path (struct usb_device *dev, char *buf, size_t size)
503 * specific class of interfaces. 521 * specific class of interfaces.
504 */ 522 */
505#define USB_INTERFACE_INFO(cl,sc,pr) \ 523#define USB_INTERFACE_INFO(cl,sc,pr) \
506 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 524 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), \
525 .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr)
507 526
508/* -------------------------------------------------------------------------- */ 527/* ----------------------------------------------------------------------- */
509 528
510/** 529/**
511 * struct usb_driver - identifies USB driver to usbcore 530 * struct usb_driver - identifies USB driver to usbcore
@@ -558,7 +577,8 @@ struct usb_driver {
558 577
559 void (*disconnect) (struct usb_interface *intf); 578 void (*disconnect) (struct usb_interface *intf);
560 579
561 int (*ioctl) (struct usb_interface *intf, unsigned int code, void *buf); 580 int (*ioctl) (struct usb_interface *intf, unsigned int code,
581 void *buf);
562 582
563 int (*suspend) (struct usb_interface *intf, pm_message_t message); 583 int (*suspend) (struct usb_interface *intf, pm_message_t message);
564 int (*resume) (struct usb_interface *intf); 584 int (*resume) (struct usb_interface *intf);
@@ -601,7 +621,7 @@ extern void usb_deregister_dev(struct usb_interface *intf,
601 621
602extern int usb_disabled(void); 622extern int usb_disabled(void);
603 623
604/* -------------------------------------------------------------------------- */ 624/* ----------------------------------------------------------------------- */
605 625
606/* 626/*
607 * URB support, for asynchronous request completions 627 * URB support, for asynchronous request completions
@@ -611,12 +631,14 @@ extern int usb_disabled(void);
611 * urb->transfer_flags: 631 * urb->transfer_flags:
612 */ 632 */
613#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */ 633#define URB_SHORT_NOT_OK 0x0001 /* report short reads as errors */
614#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame ignored */ 634#define URB_ISO_ASAP 0x0002 /* iso-only, urb->start_frame
635 * ignored */
615#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */ 636#define URB_NO_TRANSFER_DMA_MAP 0x0004 /* urb->transfer_dma valid on submit */
616#define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */ 637#define URB_NO_SETUP_DMA_MAP 0x0008 /* urb->setup_dma valid on submit */
617#define URB_NO_FSBR 0x0020 /* UHCI-specific */ 638#define URB_NO_FSBR 0x0020 /* UHCI-specific */
618#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUTs with short packet */ 639#define URB_ZERO_PACKET 0x0040 /* Finish bulk OUT with short packet */
619#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt needed */ 640#define URB_NO_INTERRUPT 0x0080 /* HINT: no non-error interrupt
641 * needed */
620 642
621struct usb_iso_packet_descriptor { 643struct usb_iso_packet_descriptor {
622 unsigned int offset; 644 unsigned int offset;
@@ -804,7 +826,8 @@ struct urb
804 u8 reject; /* submissions will fail */ 826 u8 reject; /* submissions will fail */
805 827
806 /* public, documented fields in the urb that can be used by drivers */ 828 /* public, documented fields in the urb that can be used by drivers */
807 struct list_head urb_list; /* list head for use by the urb owner */ 829 struct list_head urb_list; /* list head for use by the urb's
830 * current owner */
808 struct usb_device *dev; /* (in) pointer to associated device */ 831 struct usb_device *dev; /* (in) pointer to associated device */
809 unsigned int pipe; /* (in) pipe information */ 832 unsigned int pipe; /* (in) pipe information */
810 int status; /* (return) non-ISO status */ 833 int status; /* (return) non-ISO status */
@@ -817,14 +840,16 @@ struct urb
817 dma_addr_t setup_dma; /* (in) dma addr for setup_packet */ 840 dma_addr_t setup_dma; /* (in) dma addr for setup_packet */
818 int start_frame; /* (modify) start frame (ISO) */ 841 int start_frame; /* (modify) start frame (ISO) */
819 int number_of_packets; /* (in) number of ISO packets */ 842 int number_of_packets; /* (in) number of ISO packets */
820 int interval; /* (modify) transfer interval (INT/ISO) */ 843 int interval; /* (modify) transfer interval
844 * (INT/ISO) */
821 int error_count; /* (return) number of ISO errors */ 845 int error_count; /* (return) number of ISO errors */
822 void *context; /* (in) context for completion */ 846 void *context; /* (in) context for completion */
823 usb_complete_t complete; /* (in) completion routine */ 847 usb_complete_t complete; /* (in) completion routine */
824 struct usb_iso_packet_descriptor iso_frame_desc[0]; /* (in) ISO ONLY */ 848 struct usb_iso_packet_descriptor iso_frame_desc[0];
849 /* (in) ISO ONLY */
825}; 850};
826 851
827/* -------------------------------------------------------------------------- */ 852/* ----------------------------------------------------------------------- */
828 853
829/** 854/**
830 * usb_fill_control_urb - initializes a control urb 855 * usb_fill_control_urb - initializes a control urb
@@ -1049,7 +1074,7 @@ void usb_sg_cancel (struct usb_sg_request *io);
1049void usb_sg_wait (struct usb_sg_request *io); 1074void usb_sg_wait (struct usb_sg_request *io);
1050 1075
1051 1076
1052/* -------------------------------------------------------------------------- */ 1077/* ----------------------------------------------------------------------- */
1053 1078
1054/* 1079/*
1055 * For various legacy reasons, Linux has a small cookie that's paired with 1080 * For various legacy reasons, Linux has a small cookie that's paired with
@@ -1090,23 +1115,34 @@ void usb_sg_wait (struct usb_sg_request *io);
1090/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */ 1115/* The D0/D1 toggle bits ... USE WITH CAUTION (they're almost hcd-internal) */
1091#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1) 1116#define usb_gettoggle(dev, ep, out) (((dev)->toggle[out] >> (ep)) & 1)
1092#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep))) 1117#define usb_dotoggle(dev, ep, out) ((dev)->toggle[out] ^= (1 << (ep)))
1093#define usb_settoggle(dev, ep, out, bit) ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | ((bit) << (ep))) 1118#define usb_settoggle(dev, ep, out, bit) \
1119 ((dev)->toggle[out] = ((dev)->toggle[out] & ~(1 << (ep))) | \
1120 ((bit) << (ep)))
1094 1121
1095 1122
1096static inline unsigned int __create_pipe(struct usb_device *dev, unsigned int endpoint) 1123static inline unsigned int __create_pipe(struct usb_device *dev,
1124 unsigned int endpoint)
1097{ 1125{
1098 return (dev->devnum << 8) | (endpoint << 15); 1126 return (dev->devnum << 8) | (endpoint << 15);
1099} 1127}
1100 1128
1101/* Create various pipes... */ 1129/* Create various pipes... */
1102#define usb_sndctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint)) 1130#define usb_sndctrlpipe(dev,endpoint) \
1103#define usb_rcvctrlpipe(dev,endpoint) ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1131 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint))
1104#define usb_sndisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint)) 1132#define usb_rcvctrlpipe(dev,endpoint) \
1105#define usb_rcvisocpipe(dev,endpoint) ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1133 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1106#define usb_sndbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | __create_pipe(dev,endpoint)) 1134#define usb_sndisocpipe(dev,endpoint) \
1107#define usb_rcvbulkpipe(dev,endpoint) ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1135 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint))
1108#define usb_sndintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint)) 1136#define usb_rcvisocpipe(dev,endpoint) \
1109#define usb_rcvintpipe(dev,endpoint) ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1137 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1138#define usb_sndbulkpipe(dev,endpoint) \
1139 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint))
1140#define usb_rcvbulkpipe(dev,endpoint) \
1141 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1142#define usb_sndintpipe(dev,endpoint) \
1143 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint))
1144#define usb_rcvintpipe(dev,endpoint) \
1145 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN)
1110 1146
1111/*-------------------------------------------------------------------------*/ 1147/*-------------------------------------------------------------------------*/
1112 1148
@@ -1130,7 +1166,7 @@ usb_maxpacket(struct usb_device *udev, int pipe, int is_out)
1130 return le16_to_cpu(ep->desc.wMaxPacketSize); 1166 return le16_to_cpu(ep->desc.wMaxPacketSize);
1131} 1167}
1132 1168
1133/* -------------------------------------------------------------------------- */ 1169/* ----------------------------------------------------------------------- */
1134 1170
1135/* Events from the usb core */ 1171/* Events from the usb core */
1136#define USB_DEVICE_ADD 0x0001 1172#define USB_DEVICE_ADD 0x0001
@@ -1141,14 +1177,18 @@ extern void usb_register_notify(struct notifier_block *nb);
1141extern void usb_unregister_notify(struct notifier_block *nb); 1177extern void usb_unregister_notify(struct notifier_block *nb);
1142 1178
1143#ifdef DEBUG 1179#ifdef DEBUG
1144#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , __FILE__ , ## arg) 1180#define dbg(format, arg...) printk(KERN_DEBUG "%s: " format "\n" , \
1181 __FILE__ , ## arg)
1145#else 1182#else
1146#define dbg(format, arg...) do {} while (0) 1183#define dbg(format, arg...) do {} while (0)
1147#endif 1184#endif
1148 1185
1149#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , __FILE__ , ## arg) 1186#define err(format, arg...) printk(KERN_ERR "%s: " format "\n" , \
1150#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , __FILE__ , ## arg) 1187 __FILE__ , ## arg)
1151#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , __FILE__ , ## arg) 1188#define info(format, arg...) printk(KERN_INFO "%s: " format "\n" , \
1189 __FILE__ , ## arg)
1190#define warn(format, arg...) printk(KERN_WARNING "%s: " format "\n" , \
1191 __FILE__ , ## arg)
1152 1192
1153 1193
1154#endif /* __KERNEL__ */ 1194#endif /* __KERNEL__ */