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.h209
1 files changed, 117 insertions, 92 deletions
diff --git a/include/linux/usb.h b/include/linux/usb.h
index 5fc8ff73b7bb..2372e2e6b527 100644
--- a/include/linux/usb.h
+++ b/include/linux/usb.h
@@ -162,19 +162,19 @@ struct usb_interface {
162 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */ 162 unsigned needs_remote_wakeup:1; /* driver requires remote wakeup */
163 163
164 struct device dev; /* interface specific device info */ 164 struct device dev; /* interface specific device info */
165 struct device *usb_dev; /* pointer to the usb class's device, if any */ 165 struct device *usb_dev;
166 int pm_usage_cnt; /* usage counter for autosuspend */ 166 int pm_usage_cnt; /* usage counter for autosuspend */
167}; 167};
168#define to_usb_interface(d) container_of(d, struct usb_interface, dev) 168#define to_usb_interface(d) container_of(d, struct usb_interface, dev)
169#define interface_to_usbdev(intf) \ 169#define interface_to_usbdev(intf) \
170 container_of(intf->dev.parent, struct usb_device, dev) 170 container_of(intf->dev.parent, struct usb_device, dev)
171 171
172static inline void *usb_get_intfdata (struct usb_interface *intf) 172static inline void *usb_get_intfdata(struct usb_interface *intf)
173{ 173{
174 return dev_get_drvdata (&intf->dev); 174 return dev_get_drvdata(&intf->dev);
175} 175}
176 176
177static inline void usb_set_intfdata (struct usb_interface *intf, void *data) 177static inline void usb_set_intfdata(struct usb_interface *intf, void *data)
178{ 178{
179 dev_set_drvdata(&intf->dev, data); 179 dev_set_drvdata(&intf->dev, data);
180} 180}
@@ -275,9 +275,10 @@ struct usb_host_config {
275 275
276int __usb_get_extra_descriptor(char *buffer, unsigned size, 276int __usb_get_extra_descriptor(char *buffer, unsigned size,
277 unsigned char type, void **ptr); 277 unsigned char type, void **ptr);
278#define usb_get_extra_descriptor(ifpoint,type,ptr)\ 278#define usb_get_extra_descriptor(ifpoint, type, ptr) \
279 __usb_get_extra_descriptor((ifpoint)->extra,(ifpoint)->extralen,\ 279 __usb_get_extra_descriptor((ifpoint)->extra, \
280 type,(void**)ptr) 280 (ifpoint)->extralen, \
281 type, (void **)ptr)
281 282
282/* ----------------------------------------------------------------------- */ 283/* ----------------------------------------------------------------------- */
283 284
@@ -318,7 +319,7 @@ struct usb_bus {
318#ifdef CONFIG_USB_DEVICEFS 319#ifdef CONFIG_USB_DEVICEFS
319 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */ 320 struct dentry *usbfs_dentry; /* usbfs dentry entry for the bus */
320#endif 321#endif
321 struct class_device *class_dev; /* class device for this bus */ 322 struct device *dev; /* device for this bus */
322 323
323#if defined(CONFIG_USB_MON) 324#if defined(CONFIG_USB_MON)
324 struct mon_bus *mon_bus; /* non-null when associated */ 325 struct mon_bus *mon_bus; /* non-null when associated */
@@ -388,7 +389,7 @@ struct usb_device {
388 unsigned can_submit:1; /* URBs may be submitted */ 389 unsigned can_submit:1; /* URBs may be submitted */
389 unsigned discon_suspended:1; /* Disconnected while suspended */ 390 unsigned discon_suspended:1; /* Disconnected while suspended */
390 unsigned have_langid:1; /* whether string_langid is valid */ 391 unsigned have_langid:1; /* whether string_langid is valid */
391 unsigned authorized:1; /* Policy has determined we can use it */ 392 unsigned authorized:1; /* Policy has said we can use it */
392 unsigned wusb:1; /* Device is Wireless USB */ 393 unsigned wusb:1; /* Device is Wireless USB */
393 int string_langid; /* language ID for strings */ 394 int string_langid; /* language ID for strings */
394 395
@@ -417,7 +418,10 @@ struct usb_device {
417 418
418 int pm_usage_cnt; /* usage counter for autosuspend */ 419 int pm_usage_cnt; /* usage counter for autosuspend */
419 u32 quirks; /* quirks of the whole device */ 420 u32 quirks; /* quirks of the whole device */
420 atomic_t urbnum; /* number of URBs submitted for the whole device */ 421 atomic_t urbnum; /* number of URBs submitted for
422 the whole device */
423
424 unsigned long active_duration; /* total time device is not suspended */
421 425
422#ifdef CONFIG_PM 426#ifdef CONFIG_PM
423 struct delayed_work autosuspend; /* for delayed autosuspends */ 427 struct delayed_work autosuspend; /* for delayed autosuspends */
@@ -425,6 +429,7 @@ struct usb_device {
425 429
426 unsigned long last_busy; /* time of last use */ 430 unsigned long last_busy; /* time of last use */
427 int autosuspend_delay; /* in jiffies */ 431 int autosuspend_delay; /* in jiffies */
432 unsigned long connect_time; /* time device was first connected */
428 433
429 unsigned auto_pm:1; /* autosuspend/resume in progress */ 434 unsigned auto_pm:1; /* autosuspend/resume in progress */
430 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */ 435 unsigned do_remote_wakeup:1; /* remote wakeup should be enabled */
@@ -498,11 +503,11 @@ static inline void usb_mark_last_busy(struct usb_device *udev)
498/*-------------------------------------------------------------------------*/ 503/*-------------------------------------------------------------------------*/
499 504
500/* for drivers using iso endpoints */ 505/* for drivers using iso endpoints */
501extern int usb_get_current_frame_number (struct usb_device *usb_dev); 506extern int usb_get_current_frame_number(struct usb_device *usb_dev);
502 507
503/* used these for multi-interface device registration */ 508/* used these for multi-interface device registration */
504extern int usb_driver_claim_interface(struct usb_driver *driver, 509extern int usb_driver_claim_interface(struct usb_driver *driver,
505 struct usb_interface *iface, void* priv); 510 struct usb_interface *iface, void *priv);
506 511
507/** 512/**
508 * usb_interface_claimed - returns true iff an interface is claimed 513 * usb_interface_claimed - returns true iff an interface is claimed
@@ -514,7 +519,8 @@ extern int usb_driver_claim_interface(struct usb_driver *driver,
514 * may need to explicitly claim that lock. 519 * may need to explicitly claim that lock.
515 * 520 *
516 */ 521 */
517static inline int usb_interface_claimed(struct usb_interface *iface) { 522static inline int usb_interface_claimed(struct usb_interface *iface)
523{
518 return (iface->dev.driver != NULL); 524 return (iface->dev.driver != NULL);
519} 525}
520 526
@@ -557,12 +563,11 @@ extern struct usb_host_interface *usb_altnum_to_altsetting(
557 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are 563 * USB 2.0 root hubs (EHCI host controllers) will get one path ID if they are
558 * high speed, and a different one if they are full or low speed. 564 * high speed, and a different one if they are full or low speed.
559 */ 565 */
560static inline int usb_make_path (struct usb_device *dev, char *buf, 566static inline int usb_make_path(struct usb_device *dev, char *buf, size_t size)
561 size_t size)
562{ 567{
563 int actual; 568 int actual;
564 actual = snprintf (buf, size, "usb-%s-%s", dev->bus->bus_name, 569 actual = snprintf(buf, size, "usb-%s-%s", dev->bus->bus_name,
565 dev->devpath); 570 dev->devpath);
566 return (actual >= (int)size) ? -1 : actual; 571 return (actual >= (int)size) ? -1 : actual;
567} 572}
568 573
@@ -608,7 +613,8 @@ static inline int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd)
608 * 613 *
609 * Returns true if the endpoint is of type OUT, otherwise it returns false. 614 * Returns true if the endpoint is of type OUT, otherwise it returns false.
610 */ 615 */
611static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) 616static inline int usb_endpoint_dir_out(
617 const struct usb_endpoint_descriptor *epd)
612{ 618{
613 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); 619 return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT);
614} 620}
@@ -619,7 +625,8 @@ static inline int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd
619 * 625 *
620 * Returns true if the endpoint is of type bulk, otherwise it returns false. 626 * Returns true if the endpoint is of type bulk, otherwise it returns false.
621 */ 627 */
622static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) 628static inline int usb_endpoint_xfer_bulk(
629 const struct usb_endpoint_descriptor *epd)
623{ 630{
624 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 631 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
625 USB_ENDPOINT_XFER_BULK); 632 USB_ENDPOINT_XFER_BULK);
@@ -631,7 +638,8 @@ static inline int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *e
631 * 638 *
632 * Returns true if the endpoint is of type control, otherwise it returns false. 639 * Returns true if the endpoint is of type control, otherwise it returns false.
633 */ 640 */
634static inline int usb_endpoint_xfer_control(const struct usb_endpoint_descriptor *epd) 641static inline int usb_endpoint_xfer_control(
642 const struct usb_endpoint_descriptor *epd)
635{ 643{
636 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 644 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
637 USB_ENDPOINT_XFER_CONTROL); 645 USB_ENDPOINT_XFER_CONTROL);
@@ -644,7 +652,8 @@ static inline int usb_endpoint_xfer_control(const struct usb_endpoint_descriptor
644 * Returns true if the endpoint is of type interrupt, otherwise it returns 652 * Returns true if the endpoint is of type interrupt, otherwise it returns
645 * false. 653 * false.
646 */ 654 */
647static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) 655static inline int usb_endpoint_xfer_int(
656 const struct usb_endpoint_descriptor *epd)
648{ 657{
649 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 658 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
650 USB_ENDPOINT_XFER_INT); 659 USB_ENDPOINT_XFER_INT);
@@ -657,7 +666,8 @@ static inline int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *ep
657 * Returns true if the endpoint is of type isochronous, otherwise it returns 666 * Returns true if the endpoint is of type isochronous, otherwise it returns
658 * false. 667 * false.
659 */ 668 */
660static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) 669static inline int usb_endpoint_xfer_isoc(
670 const struct usb_endpoint_descriptor *epd)
661{ 671{
662 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == 672 return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) ==
663 USB_ENDPOINT_XFER_ISOC); 673 USB_ENDPOINT_XFER_ISOC);
@@ -670,7 +680,8 @@ static inline int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *e
670 * Returns true if the endpoint has bulk transfer type and IN direction, 680 * Returns true if the endpoint has bulk transfer type and IN direction,
671 * otherwise it returns false. 681 * otherwise it returns false.
672 */ 682 */
673static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) 683static inline int usb_endpoint_is_bulk_in(
684 const struct usb_endpoint_descriptor *epd)
674{ 685{
675 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); 686 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd));
676} 687}
@@ -682,7 +693,8 @@ static inline int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *
682 * Returns true if the endpoint has bulk transfer type and OUT direction, 693 * Returns true if the endpoint has bulk transfer type and OUT direction,
683 * otherwise it returns false. 694 * otherwise it returns false.
684 */ 695 */
685static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) 696static inline int usb_endpoint_is_bulk_out(
697 const struct usb_endpoint_descriptor *epd)
686{ 698{
687 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); 699 return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd));
688} 700}
@@ -694,7 +706,8 @@ static inline int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor
694 * Returns true if the endpoint has interrupt transfer type and IN direction, 706 * Returns true if the endpoint has interrupt transfer type and IN direction,
695 * otherwise it returns false. 707 * otherwise it returns false.
696 */ 708 */
697static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) 709static inline int usb_endpoint_is_int_in(
710 const struct usb_endpoint_descriptor *epd)
698{ 711{
699 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); 712 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd));
700} 713}
@@ -706,7 +719,8 @@ static inline int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *e
706 * Returns true if the endpoint has interrupt transfer type and OUT direction, 719 * Returns true if the endpoint has interrupt transfer type and OUT direction,
707 * otherwise it returns false. 720 * otherwise it returns false.
708 */ 721 */
709static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) 722static inline int usb_endpoint_is_int_out(
723 const struct usb_endpoint_descriptor *epd)
710{ 724{
711 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); 725 return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd));
712} 726}
@@ -718,7 +732,8 @@ static inline int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *
718 * Returns true if the endpoint has isochronous transfer type and IN direction, 732 * Returns true if the endpoint has isochronous transfer type and IN direction,
719 * otherwise it returns false. 733 * otherwise it returns false.
720 */ 734 */
721static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) 735static inline int usb_endpoint_is_isoc_in(
736 const struct usb_endpoint_descriptor *epd)
722{ 737{
723 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); 738 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd));
724} 739}
@@ -730,7 +745,8 @@ static inline int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *
730 * Returns true if the endpoint has isochronous transfer type and OUT direction, 745 * Returns true if the endpoint has isochronous transfer type and OUT direction,
731 * otherwise it returns false. 746 * otherwise it returns false.
732 */ 747 */
733static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) 748static inline int usb_endpoint_is_isoc_out(
749 const struct usb_endpoint_descriptor *epd)
734{ 750{
735 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); 751 return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd));
736} 752}
@@ -761,8 +777,9 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
761 * specific device. 777 * specific device.
762 */ 778 */
763#define USB_DEVICE(vend,prod) \ 779#define USB_DEVICE(vend,prod) \
764 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, .idVendor = (vend), \ 780 .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \
765 .idProduct = (prod) 781 .idVendor = (vend), \
782 .idProduct = (prod)
766/** 783/**
767 * USB_DEVICE_VER - macro used to describe a specific usb device with a 784 * USB_DEVICE_VER - macro used to describe a specific usb device with a
768 * version range 785 * version range
@@ -774,10 +791,12 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
774 * This macro is used to create a struct usb_device_id that matches a 791 * This macro is used to create a struct usb_device_id that matches a
775 * specific device, with a version range. 792 * specific device, with a version range.
776 */ 793 */
777#define USB_DEVICE_VER(vend,prod,lo,hi) \ 794#define USB_DEVICE_VER(vend, prod, lo, hi) \
778 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \ 795 .match_flags = USB_DEVICE_ID_MATCH_DEVICE_AND_VERSION, \
779 .idVendor = (vend), .idProduct = (prod), \ 796 .idVendor = (vend), \
780 .bcdDevice_lo = (lo), .bcdDevice_hi = (hi) 797 .idProduct = (prod), \
798 .bcdDevice_lo = (lo), \
799 .bcdDevice_hi = (hi)
781 800
782/** 801/**
783 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb 802 * USB_DEVICE_INTERFACE_PROTOCOL - macro used to describe a usb
@@ -789,8 +808,9 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
789 * This macro is used to create a struct usb_device_id that matches a 808 * This macro is used to create a struct usb_device_id that matches a
790 * specific interface protocol of devices. 809 * specific interface protocol of devices.
791 */ 810 */
792#define USB_DEVICE_INTERFACE_PROTOCOL(vend,prod,pr) \ 811#define USB_DEVICE_INTERFACE_PROTOCOL(vend, prod, pr) \
793 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | USB_DEVICE_ID_MATCH_INT_PROTOCOL, \ 812 .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \
813 USB_DEVICE_ID_MATCH_INT_PROTOCOL, \
794 .idVendor = (vend), \ 814 .idVendor = (vend), \
795 .idProduct = (prod), \ 815 .idProduct = (prod), \
796 .bInterfaceProtocol = (pr) 816 .bInterfaceProtocol = (pr)
@@ -804,12 +824,14 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
804 * This macro is used to create a struct usb_device_id that matches a 824 * This macro is used to create a struct usb_device_id that matches a
805 * specific class of devices. 825 * specific class of devices.
806 */ 826 */
807#define USB_DEVICE_INFO(cl,sc,pr) \ 827#define USB_DEVICE_INFO(cl, sc, pr) \
808 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, .bDeviceClass = (cl), \ 828 .match_flags = USB_DEVICE_ID_MATCH_DEV_INFO, \
809 .bDeviceSubClass = (sc), .bDeviceProtocol = (pr) 829 .bDeviceClass = (cl), \
830 .bDeviceSubClass = (sc), \
831 .bDeviceProtocol = (pr)
810 832
811/** 833/**
812 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces 834 * USB_INTERFACE_INFO - macro used to describe a class of usb interfaces
813 * @cl: bInterfaceClass value 835 * @cl: bInterfaceClass value
814 * @sc: bInterfaceSubClass value 836 * @sc: bInterfaceSubClass value
815 * @pr: bInterfaceProtocol value 837 * @pr: bInterfaceProtocol value
@@ -817,9 +839,11 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
817 * This macro is used to create a struct usb_device_id that matches a 839 * This macro is used to create a struct usb_device_id that matches a
818 * specific class of interfaces. 840 * specific class of interfaces.
819 */ 841 */
820#define USB_INTERFACE_INFO(cl,sc,pr) \ 842#define USB_INTERFACE_INFO(cl, sc, pr) \
821 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, .bInterfaceClass = (cl), \ 843 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO, \
822 .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 844 .bInterfaceClass = (cl), \
845 .bInterfaceSubClass = (sc), \
846 .bInterfaceProtocol = (pr)
823 847
824/** 848/**
825 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device 849 * USB_DEVICE_AND_INTERFACE_INFO - macro used to describe a specific usb device
@@ -836,12 +860,14 @@ static inline int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor
836 * This is especially useful when explicitly matching devices that have 860 * This is especially useful when explicitly matching devices that have
837 * vendor specific bDeviceClass values, but standards-compliant interfaces. 861 * vendor specific bDeviceClass values, but standards-compliant interfaces.
838 */ 862 */
839#define USB_DEVICE_AND_INTERFACE_INFO(vend,prod,cl,sc,pr) \ 863#define USB_DEVICE_AND_INTERFACE_INFO(vend, prod, cl, sc, pr) \
840 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ 864 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
841 | USB_DEVICE_ID_MATCH_DEVICE, \ 865 | USB_DEVICE_ID_MATCH_DEVICE, \
842 .idVendor = (vend), .idProduct = (prod), \ 866 .idVendor = (vend), \
867 .idProduct = (prod), \
843 .bInterfaceClass = (cl), \ 868 .bInterfaceClass = (cl), \
844 .bInterfaceSubClass = (sc), .bInterfaceProtocol = (pr) 869 .bInterfaceSubClass = (sc), \
870 .bInterfaceProtocol = (pr)
845 871
846/* ----------------------------------------------------------------------- */ 872/* ----------------------------------------------------------------------- */
847 873
@@ -1119,7 +1145,7 @@ typedef void (*usb_complete_t)(struct urb *);
1119 * transferred. It will normally be the same as requested, unless 1145 * transferred. It will normally be the same as requested, unless
1120 * either an error was reported or a short read was performed. 1146 * either an error was reported or a short read was performed.
1121 * The URB_SHORT_NOT_OK transfer flag may be used to make such 1147 * The URB_SHORT_NOT_OK transfer flag may be used to make such
1122 * short reads be reported as errors. 1148 * short reads be reported as errors.
1123 * @setup_packet: Only used for control transfers, this points to eight bytes 1149 * @setup_packet: Only used for control transfers, this points to eight bytes
1124 * of setup data. Control transfers always start by sending this data 1150 * of setup data. Control transfers always start by sending this data
1125 * to the device. Then transfer_buffer is read or written, if needed. 1151 * to the device. Then transfer_buffer is read or written, if needed.
@@ -1138,7 +1164,7 @@ typedef void (*usb_complete_t)(struct urb *);
1138 * @complete: Completion handler. This URB is passed as the parameter to the 1164 * @complete: Completion handler. This URB is passed as the parameter to the
1139 * completion function. The completion function may then do what 1165 * completion function. The completion function may then do what
1140 * it likes with the URB, including resubmitting or freeing it. 1166 * it likes with the URB, including resubmitting or freeing it.
1141 * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to 1167 * @iso_frame_desc: Used to provide arrays of ISO transfer buffers and to
1142 * collect the transfer status for each buffer. 1168 * collect the transfer status for each buffer.
1143 * 1169 *
1144 * This structure identifies USB transfer requests. URBs must be allocated by 1170 * This structure identifies USB transfer requests. URBs must be allocated by
@@ -1242,8 +1268,7 @@ typedef void (*usb_complete_t)(struct urb *);
1242 * when the urb is owned by the hcd, that is, since the call to 1268 * when the urb is owned by the hcd, that is, since the call to
1243 * usb_submit_urb() till the entry into the completion routine. 1269 * usb_submit_urb() till the entry into the completion routine.
1244 */ 1270 */
1245struct urb 1271struct urb {
1246{
1247 /* private: usb core and host controller only fields in the urb */ 1272 /* private: usb core and host controller only fields in the urb */
1248 struct kref kref; /* reference count of the URB */ 1273 struct kref kref; /* reference count of the URB */
1249 void *hcpriv; /* private data for host controller */ 1274 void *hcpriv; /* private data for host controller */
@@ -1254,10 +1279,10 @@ struct urb
1254 /* public: documented fields in the urb that can be used by drivers */ 1279 /* public: documented fields in the urb that can be used by drivers */
1255 struct list_head urb_list; /* list head for use by the urb's 1280 struct list_head urb_list; /* list head for use by the urb's
1256 * current owner */ 1281 * current owner */
1257 struct list_head anchor_list; /* the URB may be anchored by the driver */ 1282 struct list_head anchor_list; /* the URB may be anchored */
1258 struct usb_anchor *anchor; 1283 struct usb_anchor *anchor;
1259 struct usb_device *dev; /* (in) pointer to associated device */ 1284 struct usb_device *dev; /* (in) pointer to associated device */
1260 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint struct */ 1285 struct usb_host_endpoint *ep; /* (internal) pointer to endpoint */
1261 unsigned int pipe; /* (in) pipe information */ 1286 unsigned int pipe; /* (in) pipe information */
1262 int status; /* (return) non-ISO status */ 1287 int status; /* (return) non-ISO status */
1263 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/ 1288 unsigned int transfer_flags; /* (in) URB_SHORT_NOT_OK | ...*/
@@ -1294,14 +1319,14 @@ struct urb
1294 * Initializes a control urb with the proper information needed to submit 1319 * Initializes a control urb with the proper information needed to submit
1295 * it to a device. 1320 * it to a device.
1296 */ 1321 */
1297static inline void usb_fill_control_urb (struct urb *urb, 1322static inline void usb_fill_control_urb(struct urb *urb,
1298 struct usb_device *dev, 1323 struct usb_device *dev,
1299 unsigned int pipe, 1324 unsigned int pipe,
1300 unsigned char *setup_packet, 1325 unsigned char *setup_packet,
1301 void *transfer_buffer, 1326 void *transfer_buffer,
1302 int buffer_length, 1327 int buffer_length,
1303 usb_complete_t complete_fn, 1328 usb_complete_t complete_fn,
1304 void *context) 1329 void *context)
1305{ 1330{
1306 urb->dev = dev; 1331 urb->dev = dev;
1307 urb->pipe = pipe; 1332 urb->pipe = pipe;
@@ -1325,13 +1350,13 @@ static inline void usb_fill_control_urb (struct urb *urb,
1325 * Initializes a bulk urb with the proper information needed to submit it 1350 * Initializes a bulk urb with the proper information needed to submit it
1326 * to a device. 1351 * to a device.
1327 */ 1352 */
1328static inline void usb_fill_bulk_urb (struct urb *urb, 1353static inline void usb_fill_bulk_urb(struct urb *urb,
1329 struct usb_device *dev, 1354 struct usb_device *dev,
1330 unsigned int pipe, 1355 unsigned int pipe,
1331 void *transfer_buffer, 1356 void *transfer_buffer,
1332 int buffer_length, 1357 int buffer_length,
1333 usb_complete_t complete_fn, 1358 usb_complete_t complete_fn,
1334 void *context) 1359 void *context)
1335{ 1360{
1336 urb->dev = dev; 1361 urb->dev = dev;
1337 urb->pipe = pipe; 1362 urb->pipe = pipe;
@@ -1359,14 +1384,14 @@ static inline void usb_fill_bulk_urb (struct urb *urb,
1359 * the endpoint interval, and express polling intervals in microframes 1384 * the endpoint interval, and express polling intervals in microframes
1360 * (eight per millisecond) rather than in frames (one per millisecond). 1385 * (eight per millisecond) rather than in frames (one per millisecond).
1361 */ 1386 */
1362static inline void usb_fill_int_urb (struct urb *urb, 1387static inline void usb_fill_int_urb(struct urb *urb,
1363 struct usb_device *dev, 1388 struct usb_device *dev,
1364 unsigned int pipe, 1389 unsigned int pipe,
1365 void *transfer_buffer, 1390 void *transfer_buffer,
1366 int buffer_length, 1391 int buffer_length,
1367 usb_complete_t complete_fn, 1392 usb_complete_t complete_fn,
1368 void *context, 1393 void *context,
1369 int interval) 1394 int interval)
1370{ 1395{
1371 urb->dev = dev; 1396 urb->dev = dev;
1372 urb->pipe = pipe; 1397 urb->pipe = pipe;
@@ -1419,15 +1444,15 @@ static inline int usb_urb_dir_out(struct urb *urb)
1419 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT; 1444 return (urb->transfer_flags & URB_DIR_MASK) == URB_DIR_OUT;
1420} 1445}
1421 1446
1422void *usb_buffer_alloc (struct usb_device *dev, size_t size, 1447void *usb_buffer_alloc(struct usb_device *dev, size_t size,
1423 gfp_t mem_flags, dma_addr_t *dma); 1448 gfp_t mem_flags, dma_addr_t *dma);
1424void usb_buffer_free (struct usb_device *dev, size_t size, 1449void usb_buffer_free(struct usb_device *dev, size_t size,
1425 void *addr, dma_addr_t dma); 1450 void *addr, dma_addr_t dma);
1426 1451
1427#if 0 1452#if 0
1428struct urb *usb_buffer_map (struct urb *urb); 1453struct urb *usb_buffer_map(struct urb *urb);
1429void usb_buffer_dmasync (struct urb *urb); 1454void usb_buffer_dmasync(struct urb *urb);
1430void usb_buffer_unmap (struct urb *urb); 1455void usb_buffer_unmap(struct urb *urb);
1431#endif 1456#endif
1432 1457
1433struct scatterlist; 1458struct scatterlist;
@@ -1499,7 +1524,7 @@ struct usb_sg_request {
1499 int status; 1524 int status;
1500 size_t bytes; 1525 size_t bytes;
1501 1526
1502 /* 1527 /*
1503 * members below are private: to usbcore, 1528 * members below are private: to usbcore,
1504 * and are not provided for driver access! 1529 * and are not provided for driver access!
1505 */ 1530 */
@@ -1517,18 +1542,18 @@ struct usb_sg_request {
1517 struct completion complete; 1542 struct completion complete;
1518}; 1543};
1519 1544
1520int usb_sg_init ( 1545int usb_sg_init(
1521 struct usb_sg_request *io, 1546 struct usb_sg_request *io,
1522 struct usb_device *dev, 1547 struct usb_device *dev,
1523 unsigned pipe, 1548 unsigned pipe,
1524 unsigned period, 1549 unsigned period,
1525 struct scatterlist *sg, 1550 struct scatterlist *sg,
1526 int nents, 1551 int nents,
1527 size_t length, 1552 size_t length,
1528 gfp_t mem_flags 1553 gfp_t mem_flags
1529); 1554);
1530void usb_sg_cancel (struct usb_sg_request *io); 1555void usb_sg_cancel(struct usb_sg_request *io);
1531void usb_sg_wait (struct usb_sg_request *io); 1556void usb_sg_wait(struct usb_sg_request *io);
1532 1557
1533 1558
1534/* ----------------------------------------------------------------------- */ 1559/* ----------------------------------------------------------------------- */
@@ -1585,21 +1610,21 @@ static inline unsigned int __create_pipe(struct usb_device *dev,
1585 1610
1586/* Create various pipes... */ 1611/* Create various pipes... */
1587#define usb_sndctrlpipe(dev,endpoint) \ 1612#define usb_sndctrlpipe(dev,endpoint) \
1588 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint)) 1613 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint))
1589#define usb_rcvctrlpipe(dev,endpoint) \ 1614#define usb_rcvctrlpipe(dev,endpoint) \
1590 ((PIPE_CONTROL << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1615 ((PIPE_CONTROL << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1591#define usb_sndisocpipe(dev,endpoint) \ 1616#define usb_sndisocpipe(dev,endpoint) \
1592 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint)) 1617 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint))
1593#define usb_rcvisocpipe(dev,endpoint) \ 1618#define usb_rcvisocpipe(dev,endpoint) \
1594 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1619 ((PIPE_ISOCHRONOUS << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1595#define usb_sndbulkpipe(dev,endpoint) \ 1620#define usb_sndbulkpipe(dev,endpoint) \
1596 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint)) 1621 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint))
1597#define usb_rcvbulkpipe(dev,endpoint) \ 1622#define usb_rcvbulkpipe(dev,endpoint) \
1598 ((PIPE_BULK << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1623 ((PIPE_BULK << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1599#define usb_sndintpipe(dev,endpoint) \ 1624#define usb_sndintpipe(dev,endpoint) \
1600 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint)) 1625 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint))
1601#define usb_rcvintpipe(dev,endpoint) \ 1626#define usb_rcvintpipe(dev,endpoint) \
1602 ((PIPE_INTERRUPT << 30) | __create_pipe(dev,endpoint) | USB_DIR_IN) 1627 ((PIPE_INTERRUPT << 30) | __create_pipe(dev, endpoint) | USB_DIR_IN)
1603 1628
1604/*-------------------------------------------------------------------------*/ 1629/*-------------------------------------------------------------------------*/
1605 1630