diff options
Diffstat (limited to 'drivers/usb/core')
-rw-r--r-- | drivers/usb/core/Kconfig | 15 | ||||
-rw-r--r-- | drivers/usb/core/devices.c | 9 | ||||
-rw-r--r-- | drivers/usb/core/devio.c | 12 | ||||
-rw-r--r-- | drivers/usb/core/driver.c | 304 | ||||
-rw-r--r-- | drivers/usb/core/endpoint.c | 118 | ||||
-rw-r--r-- | drivers/usb/core/hcd.c | 4 | ||||
-rw-r--r-- | drivers/usb/core/hub.c | 237 | ||||
-rw-r--r-- | drivers/usb/core/hub.h | 41 | ||||
-rw-r--r-- | drivers/usb/core/message.c | 13 | ||||
-rw-r--r-- | drivers/usb/core/usb.c | 160 | ||||
-rw-r--r-- | drivers/usb/core/usb.h | 9 |
11 files changed, 505 insertions, 417 deletions
diff --git a/drivers/usb/core/Kconfig b/drivers/usb/core/Kconfig index 6e3b5358a760..f8324d8d06ac 100644 --- a/drivers/usb/core/Kconfig +++ b/drivers/usb/core/Kconfig | |||
@@ -72,6 +72,21 @@ config USB_SUSPEND | |||
72 | 72 | ||
73 | If you are unsure about this, say N here. | 73 | If you are unsure about this, say N here. |
74 | 74 | ||
75 | config USB_MULTITHREAD_PROBE | ||
76 | bool "USB Multi-threaded probe (EXPERIMENTAL)" | ||
77 | depends on USB && EXPERIMENTAL | ||
78 | default n | ||
79 | help | ||
80 | Say Y here if you want the USB core to spawn a new thread for | ||
81 | every USB device that is probed. This can cause a small speedup | ||
82 | in boot times on systems with a lot of different USB devices. | ||
83 | |||
84 | This option should be safe to enable, but if any odd probing | ||
85 | problems are found, please disable it, or dynamically turn it | ||
86 | off in the /sys/module/usbcore/parameters/multithread_probe | ||
87 | file | ||
88 | |||
89 | When in doubt, say N. | ||
75 | 90 | ||
76 | config USB_OTG | 91 | config USB_OTG |
77 | bool | 92 | bool |
diff --git a/drivers/usb/core/devices.c b/drivers/usb/core/devices.c index 3538c2fdadfe..ea398e5d50af 100644 --- a/drivers/usb/core/devices.c +++ b/drivers/usb/core/devices.c | |||
@@ -175,12 +175,13 @@ static char *usb_dump_endpoint_descriptor ( | |||
175 | ) | 175 | ) |
176 | { | 176 | { |
177 | char dir, unit, *type; | 177 | char dir, unit, *type; |
178 | unsigned interval, in, bandwidth = 1; | 178 | unsigned interval, bandwidth = 1; |
179 | 179 | ||
180 | if (start > end) | 180 | if (start > end) |
181 | return start; | 181 | return start; |
182 | in = (desc->bEndpointAddress & USB_DIR_IN); | 182 | |
183 | dir = in ? 'I' : 'O'; | 183 | dir = usb_endpoint_dir_in(desc) ? 'I' : 'O'; |
184 | |||
184 | if (speed == USB_SPEED_HIGH) { | 185 | if (speed == USB_SPEED_HIGH) { |
185 | switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) { | 186 | switch (le16_to_cpu(desc->wMaxPacketSize) & (0x03 << 11)) { |
186 | case 1 << 11: bandwidth = 2; break; | 187 | case 1 << 11: bandwidth = 2; break; |
@@ -204,7 +205,7 @@ static char *usb_dump_endpoint_descriptor ( | |||
204 | break; | 205 | break; |
205 | case USB_ENDPOINT_XFER_BULK: | 206 | case USB_ENDPOINT_XFER_BULK: |
206 | type = "Bulk"; | 207 | type = "Bulk"; |
207 | if (speed == USB_SPEED_HIGH && !in) /* uframes per NAK */ | 208 | if (speed == USB_SPEED_HIGH && dir == 'O') /* uframes per NAK */ |
208 | interval = desc->bInterval; | 209 | interval = desc->bInterval; |
209 | else | 210 | else |
210 | interval = 0; | 211 | interval = 0; |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 724822cac2b1..3ed4cb2d56d9 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
@@ -561,7 +561,7 @@ static int usbdev_open(struct inode *inode, struct file *file) | |||
561 | dev = inode->i_private; | 561 | dev = inode->i_private; |
562 | if (!dev) | 562 | if (!dev) |
563 | goto out; | 563 | goto out; |
564 | ret = usb_autoresume_device(dev, 1); | 564 | ret = usb_autoresume_device(dev); |
565 | if (ret) | 565 | if (ret) |
566 | goto out; | 566 | goto out; |
567 | 567 | ||
@@ -609,7 +609,7 @@ static int usbdev_release(struct inode *inode, struct file *file) | |||
609 | releaseintf(ps, ifnum); | 609 | releaseintf(ps, ifnum); |
610 | } | 610 | } |
611 | destroy_all_async(ps); | 611 | destroy_all_async(ps); |
612 | usb_autosuspend_device(dev, 1); | 612 | usb_autosuspend_device(dev); |
613 | usb_unlock_device(dev); | 613 | usb_unlock_device(dev); |
614 | usb_put_dev(dev); | 614 | usb_put_dev(dev); |
615 | put_pid(ps->disc_pid); | 615 | put_pid(ps->disc_pid); |
@@ -1588,15 +1588,18 @@ const struct file_operations usbfs_device_file_operations = { | |||
1588 | .release = usbdev_release, | 1588 | .release = usbdev_release, |
1589 | }; | 1589 | }; |
1590 | 1590 | ||
1591 | static void usbdev_add(struct usb_device *dev) | 1591 | static int usbdev_add(struct usb_device *dev) |
1592 | { | 1592 | { |
1593 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); | 1593 | int minor = ((dev->bus->busnum-1) * 128) + (dev->devnum-1); |
1594 | 1594 | ||
1595 | dev->class_dev = class_device_create(usb_device_class, NULL, | 1595 | dev->class_dev = class_device_create(usb_device_class, NULL, |
1596 | MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, | 1596 | MKDEV(USB_DEVICE_MAJOR, minor), &dev->dev, |
1597 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); | 1597 | "usbdev%d.%d", dev->bus->busnum, dev->devnum); |
1598 | if (IS_ERR(dev->class_dev)) | ||
1599 | return PTR_ERR(dev->class_dev); | ||
1598 | 1600 | ||
1599 | dev->class_dev->class_data = dev; | 1601 | dev->class_dev->class_data = dev; |
1602 | return 0; | ||
1600 | } | 1603 | } |
1601 | 1604 | ||
1602 | static void usbdev_remove(struct usb_device *dev) | 1605 | static void usbdev_remove(struct usb_device *dev) |
@@ -1609,7 +1612,8 @@ static int usbdev_notify(struct notifier_block *self, unsigned long action, | |||
1609 | { | 1612 | { |
1610 | switch (action) { | 1613 | switch (action) { |
1611 | case USB_DEVICE_ADD: | 1614 | case USB_DEVICE_ADD: |
1612 | usbdev_add(dev); | 1615 | if (usbdev_add(dev)) |
1616 | return NOTIFY_BAD; | ||
1613 | break; | 1617 | break; |
1614 | case USB_DEVICE_REMOVE: | 1618 | case USB_DEVICE_REMOVE: |
1615 | usbdev_remove(dev); | 1619 | usbdev_remove(dev); |
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 113e484c763e..d6eb5ce1dd1d 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -205,7 +205,7 @@ static int usb_probe_interface(struct device *dev) | |||
205 | if (id) { | 205 | if (id) { |
206 | dev_dbg(dev, "%s - got id\n", __FUNCTION__); | 206 | dev_dbg(dev, "%s - got id\n", __FUNCTION__); |
207 | 207 | ||
208 | error = usb_autoresume_device(udev, 1); | 208 | error = usb_autoresume_device(udev); |
209 | if (error) | 209 | if (error) |
210 | return error; | 210 | return error; |
211 | 211 | ||
@@ -229,7 +229,7 @@ static int usb_probe_interface(struct device *dev) | |||
229 | } else | 229 | } else |
230 | intf->condition = USB_INTERFACE_BOUND; | 230 | intf->condition = USB_INTERFACE_BOUND; |
231 | 231 | ||
232 | usb_autosuspend_device(udev, 1); | 232 | usb_autosuspend_device(udev); |
233 | } | 233 | } |
234 | 234 | ||
235 | return error; | 235 | return error; |
@@ -247,7 +247,7 @@ static int usb_unbind_interface(struct device *dev) | |||
247 | 247 | ||
248 | /* Autoresume for set_interface call below */ | 248 | /* Autoresume for set_interface call below */ |
249 | udev = interface_to_usbdev(intf); | 249 | udev = interface_to_usbdev(intf); |
250 | error = usb_autoresume_device(udev, 1); | 250 | error = usb_autoresume_device(udev); |
251 | 251 | ||
252 | /* release all urbs for this interface */ | 252 | /* release all urbs for this interface */ |
253 | usb_disable_interface(interface_to_usbdev(intf), intf); | 253 | usb_disable_interface(interface_to_usbdev(intf), intf); |
@@ -265,7 +265,7 @@ static int usb_unbind_interface(struct device *dev) | |||
265 | intf->needs_remote_wakeup = 0; | 265 | intf->needs_remote_wakeup = 0; |
266 | 266 | ||
267 | if (!error) | 267 | if (!error) |
268 | usb_autosuspend_device(udev, 1); | 268 | usb_autosuspend_device(udev); |
269 | 269 | ||
270 | return 0; | 270 | return 0; |
271 | } | 271 | } |
@@ -408,6 +408,16 @@ static int usb_match_one_id(struct usb_interface *interface, | |||
408 | (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) | 408 | (id->bDeviceProtocol != dev->descriptor.bDeviceProtocol)) |
409 | return 0; | 409 | return 0; |
410 | 410 | ||
411 | /* The interface class, subclass, and protocol should never be | ||
412 | * checked for a match if the device class is Vendor Specific, | ||
413 | * unless the match record specifies the Vendor ID. */ | ||
414 | if (dev->descriptor.bDeviceClass == USB_CLASS_VENDOR_SPEC && | ||
415 | !(id->match_flags & USB_DEVICE_ID_MATCH_VENDOR) && | ||
416 | (id->match_flags & (USB_DEVICE_ID_MATCH_INT_CLASS | | ||
417 | USB_DEVICE_ID_MATCH_INT_SUBCLASS | | ||
418 | USB_DEVICE_ID_MATCH_INT_PROTOCOL))) | ||
419 | return 0; | ||
420 | |||
411 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && | 421 | if ((id->match_flags & USB_DEVICE_ID_MATCH_INT_CLASS) && |
412 | (id->bInterfaceClass != intf->desc.bInterfaceClass)) | 422 | (id->bInterfaceClass != intf->desc.bInterfaceClass)) |
413 | return 0; | 423 | return 0; |
@@ -476,7 +486,17 @@ static int usb_match_one_id(struct usb_interface *interface, | |||
476 | * most general; they let drivers bind to any interface on a | 486 | * most general; they let drivers bind to any interface on a |
477 | * multiple-function device. Use the USB_INTERFACE_INFO | 487 | * multiple-function device. Use the USB_INTERFACE_INFO |
478 | * macro, or its siblings, to match class-per-interface style | 488 | * macro, or its siblings, to match class-per-interface style |
479 | * devices (as recorded in bDeviceClass). | 489 | * devices (as recorded in bInterfaceClass). |
490 | * | ||
491 | * Note that an entry created by USB_INTERFACE_INFO won't match | ||
492 | * any interface if the device class is set to Vendor-Specific. | ||
493 | * This is deliberate; according to the USB spec the meanings of | ||
494 | * the interface class/subclass/protocol for these devices are also | ||
495 | * vendor-specific, and hence matching against a standard product | ||
496 | * class wouldn't work anyway. If you really want to use an | ||
497 | * interface-based match for such a device, create a match record | ||
498 | * that also specifies the vendor ID. (Unforunately there isn't a | ||
499 | * standard macro for creating records like this.) | ||
480 | * | 500 | * |
481 | * Within those groups, remember that not all combinations are | 501 | * Within those groups, remember that not all combinations are |
482 | * meaningful. For example, don't give a product version range | 502 | * meaningful. For example, don't give a product version range |
@@ -505,7 +525,7 @@ const struct usb_device_id *usb_match_id(struct usb_interface *interface, | |||
505 | } | 525 | } |
506 | EXPORT_SYMBOL_GPL_FUTURE(usb_match_id); | 526 | EXPORT_SYMBOL_GPL_FUTURE(usb_match_id); |
507 | 527 | ||
508 | int usb_device_match(struct device *dev, struct device_driver *drv) | 528 | static int usb_device_match(struct device *dev, struct device_driver *drv) |
509 | { | 529 | { |
510 | /* devices and interfaces are handled separately */ | 530 | /* devices and interfaces are handled separately */ |
511 | if (is_usb_device(dev)) { | 531 | if (is_usb_device(dev)) { |
@@ -790,7 +810,7 @@ EXPORT_SYMBOL_GPL_FUTURE(usb_deregister); | |||
790 | #ifdef CONFIG_PM | 810 | #ifdef CONFIG_PM |
791 | 811 | ||
792 | /* Caller has locked udev's pm_mutex */ | 812 | /* Caller has locked udev's pm_mutex */ |
793 | static int suspend_device(struct usb_device *udev, pm_message_t msg) | 813 | static int usb_suspend_device(struct usb_device *udev, pm_message_t msg) |
794 | { | 814 | { |
795 | struct usb_device_driver *udriver; | 815 | struct usb_device_driver *udriver; |
796 | int status = 0; | 816 | int status = 0; |
@@ -817,7 +837,7 @@ done: | |||
817 | } | 837 | } |
818 | 838 | ||
819 | /* Caller has locked udev's pm_mutex */ | 839 | /* Caller has locked udev's pm_mutex */ |
820 | static int resume_device(struct usb_device *udev) | 840 | static int usb_resume_device(struct usb_device *udev) |
821 | { | 841 | { |
822 | struct usb_device_driver *udriver; | 842 | struct usb_device_driver *udriver; |
823 | int status = 0; | 843 | int status = 0; |
@@ -843,7 +863,7 @@ done: | |||
843 | } | 863 | } |
844 | 864 | ||
845 | /* Caller has locked intf's usb_device's pm mutex */ | 865 | /* Caller has locked intf's usb_device's pm mutex */ |
846 | static int suspend_interface(struct usb_interface *intf, pm_message_t msg) | 866 | static int usb_suspend_interface(struct usb_interface *intf, pm_message_t msg) |
847 | { | 867 | { |
848 | struct usb_driver *driver; | 868 | struct usb_driver *driver; |
849 | int status = 0; | 869 | int status = 0; |
@@ -880,7 +900,7 @@ done: | |||
880 | } | 900 | } |
881 | 901 | ||
882 | /* Caller has locked intf's usb_device's pm_mutex */ | 902 | /* Caller has locked intf's usb_device's pm_mutex */ |
883 | static int resume_interface(struct usb_interface *intf) | 903 | static int usb_resume_interface(struct usb_interface *intf) |
884 | { | 904 | { |
885 | struct usb_driver *driver; | 905 | struct usb_driver *driver; |
886 | int status = 0; | 906 | int status = 0; |
@@ -920,6 +940,44 @@ done: | |||
920 | return status; | 940 | return status; |
921 | } | 941 | } |
922 | 942 | ||
943 | #ifdef CONFIG_USB_SUSPEND | ||
944 | |||
945 | /* Internal routine to check whether we may autosuspend a device. */ | ||
946 | static int autosuspend_check(struct usb_device *udev) | ||
947 | { | ||
948 | int i; | ||
949 | struct usb_interface *intf; | ||
950 | |||
951 | /* For autosuspend, fail fast if anything is in use. | ||
952 | * Also fail if any interfaces require remote wakeup but it | ||
953 | * isn't available. */ | ||
954 | udev->do_remote_wakeup = device_may_wakeup(&udev->dev); | ||
955 | if (udev->pm_usage_cnt > 0) | ||
956 | return -EBUSY; | ||
957 | if (udev->actconfig) { | ||
958 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { | ||
959 | intf = udev->actconfig->interface[i]; | ||
960 | if (!is_active(intf)) | ||
961 | continue; | ||
962 | if (intf->pm_usage_cnt > 0) | ||
963 | return -EBUSY; | ||
964 | if (intf->needs_remote_wakeup && | ||
965 | !udev->do_remote_wakeup) { | ||
966 | dev_dbg(&udev->dev, "remote wakeup needed " | ||
967 | "for autosuspend\n"); | ||
968 | return -EOPNOTSUPP; | ||
969 | } | ||
970 | } | ||
971 | } | ||
972 | return 0; | ||
973 | } | ||
974 | |||
975 | #else | ||
976 | |||
977 | #define autosuspend_check(udev) 0 | ||
978 | |||
979 | #endif | ||
980 | |||
923 | /** | 981 | /** |
924 | * usb_suspend_both - suspend a USB device and its interfaces | 982 | * usb_suspend_both - suspend a USB device and its interfaces |
925 | * @udev: the usb_device to suspend | 983 | * @udev: the usb_device to suspend |
@@ -971,52 +1029,34 @@ int usb_suspend_both(struct usb_device *udev, pm_message_t msg) | |||
971 | 1029 | ||
972 | udev->do_remote_wakeup = device_may_wakeup(&udev->dev); | 1030 | udev->do_remote_wakeup = device_may_wakeup(&udev->dev); |
973 | 1031 | ||
974 | /* For autosuspend, fail fast if anything is in use. | ||
975 | * Also fail if any interfaces require remote wakeup but it | ||
976 | * isn't available. */ | ||
977 | if (udev->auto_pm) { | 1032 | if (udev->auto_pm) { |
978 | if (udev->pm_usage_cnt > 0) | 1033 | status = autosuspend_check(udev); |
979 | return -EBUSY; | 1034 | if (status < 0) |
980 | if (udev->actconfig) { | 1035 | return status; |
981 | for (; i < udev->actconfig->desc.bNumInterfaces; i++) { | ||
982 | intf = udev->actconfig->interface[i]; | ||
983 | if (!is_active(intf)) | ||
984 | continue; | ||
985 | if (intf->pm_usage_cnt > 0) | ||
986 | return -EBUSY; | ||
987 | if (intf->needs_remote_wakeup && | ||
988 | !udev->do_remote_wakeup) { | ||
989 | dev_dbg(&udev->dev, | ||
990 | "remote wakeup needed for autosuspend\n"); | ||
991 | return -EOPNOTSUPP; | ||
992 | } | ||
993 | } | ||
994 | i = 0; | ||
995 | } | ||
996 | } | 1036 | } |
997 | 1037 | ||
998 | /* Suspend all the interfaces and then udev itself */ | 1038 | /* Suspend all the interfaces and then udev itself */ |
999 | if (udev->actconfig) { | 1039 | if (udev->actconfig) { |
1000 | for (; i < udev->actconfig->desc.bNumInterfaces; i++) { | 1040 | for (; i < udev->actconfig->desc.bNumInterfaces; i++) { |
1001 | intf = udev->actconfig->interface[i]; | 1041 | intf = udev->actconfig->interface[i]; |
1002 | status = suspend_interface(intf, msg); | 1042 | status = usb_suspend_interface(intf, msg); |
1003 | if (status != 0) | 1043 | if (status != 0) |
1004 | break; | 1044 | break; |
1005 | } | 1045 | } |
1006 | } | 1046 | } |
1007 | if (status == 0) | 1047 | if (status == 0) |
1008 | status = suspend_device(udev, msg); | 1048 | status = usb_suspend_device(udev, msg); |
1009 | 1049 | ||
1010 | /* If the suspend failed, resume interfaces that did get suspended */ | 1050 | /* If the suspend failed, resume interfaces that did get suspended */ |
1011 | if (status != 0) { | 1051 | if (status != 0) { |
1012 | while (--i >= 0) { | 1052 | while (--i >= 0) { |
1013 | intf = udev->actconfig->interface[i]; | 1053 | intf = udev->actconfig->interface[i]; |
1014 | resume_interface(intf); | 1054 | usb_resume_interface(intf); |
1015 | } | 1055 | } |
1016 | 1056 | ||
1017 | /* If the suspend succeeded, propagate it up the tree */ | 1057 | /* If the suspend succeeded, propagate it up the tree */ |
1018 | } else if (parent) | 1058 | } else if (parent) |
1019 | usb_autosuspend_device(parent, 0); | 1059 | usb_autosuspend_device(parent); |
1020 | 1060 | ||
1021 | // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); | 1061 | // dev_dbg(&udev->dev, "%s: status %d\n", __FUNCTION__, status); |
1022 | return status; | 1062 | return status; |
@@ -1064,9 +1104,25 @@ int usb_resume_both(struct usb_device *udev) | |||
1064 | /* Propagate the resume up the tree, if necessary */ | 1104 | /* Propagate the resume up the tree, if necessary */ |
1065 | if (udev->state == USB_STATE_SUSPENDED) { | 1105 | if (udev->state == USB_STATE_SUSPENDED) { |
1066 | if (parent) { | 1106 | if (parent) { |
1067 | usb_pm_lock(parent); | 1107 | status = usb_autoresume_device(parent); |
1068 | parent->auto_pm = 1; | 1108 | if (status == 0) { |
1069 | status = usb_resume_both(parent); | 1109 | status = usb_resume_device(udev); |
1110 | if (status) { | ||
1111 | usb_autosuspend_device(parent); | ||
1112 | |||
1113 | /* It's possible usb_resume_device() | ||
1114 | * failed after the port was | ||
1115 | * unsuspended, causing udev to be | ||
1116 | * logically disconnected. We don't | ||
1117 | * want usb_disconnect() to autosuspend | ||
1118 | * the parent again, so tell it that | ||
1119 | * udev disconnected while still | ||
1120 | * suspended. */ | ||
1121 | if (udev->state == | ||
1122 | USB_STATE_NOTATTACHED) | ||
1123 | udev->discon_suspended = 1; | ||
1124 | } | ||
1125 | } | ||
1070 | } else { | 1126 | } else { |
1071 | 1127 | ||
1072 | /* We can't progagate beyond the USB subsystem, | 1128 | /* We can't progagate beyond the USB subsystem, |
@@ -1075,24 +1131,20 @@ int usb_resume_both(struct usb_device *udev) | |||
1075 | if (udev->dev.parent->power.power_state.event != | 1131 | if (udev->dev.parent->power.power_state.event != |
1076 | PM_EVENT_ON) | 1132 | PM_EVENT_ON) |
1077 | status = -EHOSTUNREACH; | 1133 | status = -EHOSTUNREACH; |
1078 | } | 1134 | else |
1079 | if (status == 0) | 1135 | status = usb_resume_device(udev); |
1080 | status = resume_device(udev); | 1136 | } |
1081 | if (parent) | ||
1082 | usb_pm_unlock(parent); | ||
1083 | } else { | 1137 | } else { |
1084 | 1138 | ||
1085 | /* Needed only for setting udev->dev.power.power_state.event | 1139 | /* Needed only for setting udev->dev.power.power_state.event |
1086 | * and for possible debugging message. */ | 1140 | * and for possible debugging message. */ |
1087 | status = resume_device(udev); | 1141 | status = usb_resume_device(udev); |
1088 | } | 1142 | } |
1089 | 1143 | ||
1090 | /* Now the parent won't suspend until we are finished */ | ||
1091 | |||
1092 | if (status == 0 && udev->actconfig) { | 1144 | if (status == 0 && udev->actconfig) { |
1093 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { | 1145 | for (i = 0; i < udev->actconfig->desc.bNumInterfaces; i++) { |
1094 | intf = udev->actconfig->interface[i]; | 1146 | intf = udev->actconfig->interface[i]; |
1095 | resume_interface(intf); | 1147 | usb_resume_interface(intf); |
1096 | } | 1148 | } |
1097 | } | 1149 | } |
1098 | 1150 | ||
@@ -1102,39 +1154,53 @@ int usb_resume_both(struct usb_device *udev) | |||
1102 | 1154 | ||
1103 | #ifdef CONFIG_USB_SUSPEND | 1155 | #ifdef CONFIG_USB_SUSPEND |
1104 | 1156 | ||
1157 | /* Internal routine to adjust a device's usage counter and change | ||
1158 | * its autosuspend state. | ||
1159 | */ | ||
1160 | static int usb_autopm_do_device(struct usb_device *udev, int inc_usage_cnt) | ||
1161 | { | ||
1162 | int status = 0; | ||
1163 | |||
1164 | usb_pm_lock(udev); | ||
1165 | udev->pm_usage_cnt += inc_usage_cnt; | ||
1166 | WARN_ON(udev->pm_usage_cnt < 0); | ||
1167 | if (inc_usage_cnt >= 0 && udev->pm_usage_cnt > 0) { | ||
1168 | udev->auto_pm = 1; | ||
1169 | status = usb_resume_both(udev); | ||
1170 | if (status != 0) | ||
1171 | udev->pm_usage_cnt -= inc_usage_cnt; | ||
1172 | } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0) | ||
1173 | queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, | ||
1174 | USB_AUTOSUSPEND_DELAY); | ||
1175 | usb_pm_unlock(udev); | ||
1176 | return status; | ||
1177 | } | ||
1178 | |||
1105 | /** | 1179 | /** |
1106 | * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces | 1180 | * usb_autosuspend_device - delayed autosuspend of a USB device and its interfaces |
1107 | * @udev: the usb_device to autosuspend | 1181 | * @udev: the usb_device to autosuspend |
1108 | * @dec_usage_cnt: flag to decrement @udev's PM-usage counter | ||
1109 | * | 1182 | * |
1110 | * This routine should be called when a core subsystem is finished using | 1183 | * This routine should be called when a core subsystem is finished using |
1111 | * @udev and wants to allow it to autosuspend. Examples would be when | 1184 | * @udev and wants to allow it to autosuspend. Examples would be when |
1112 | * @udev's device file in usbfs is closed or after a configuration change. | 1185 | * @udev's device file in usbfs is closed or after a configuration change. |
1113 | * | 1186 | * |
1114 | * @dec_usage_cnt should be 1 if the subsystem previously incremented | 1187 | * @udev's usage counter is decremented. If it or any of the usage counters |
1115 | * @udev's usage counter (such as by passing 1 to usb_autoresume_device); | 1188 | * for an active interface is greater than 0, no autosuspend request will be |
1116 | * otherwise it should be 0. | 1189 | * queued. (If an interface driver does not support autosuspend then its |
1117 | * | 1190 | * usage counter is permanently positive.) Furthermore, if an interface |
1118 | * If the usage counter for @udev or any of its active interfaces is greater | 1191 | * driver requires remote-wakeup capability during autosuspend but remote |
1119 | * than 0, the autosuspend request will not be queued. (If an interface | 1192 | * wakeup is disabled, the autosuspend will fail. |
1120 | * driver does not support autosuspend then its usage counter is permanently | ||
1121 | * positive.) Likewise, if an interface driver requires remote-wakeup | ||
1122 | * capability during autosuspend but remote wakeup is disabled, the | ||
1123 | * autosuspend will fail. | ||
1124 | * | 1193 | * |
1125 | * Often the caller will hold @udev's device lock, but this is not | 1194 | * Often the caller will hold @udev's device lock, but this is not |
1126 | * necessary. | 1195 | * necessary. |
1127 | * | 1196 | * |
1128 | * This routine can run only in process context. | 1197 | * This routine can run only in process context. |
1129 | */ | 1198 | */ |
1130 | void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt) | 1199 | void usb_autosuspend_device(struct usb_device *udev) |
1131 | { | 1200 | { |
1132 | usb_pm_lock(udev); | 1201 | int status; |
1133 | udev->pm_usage_cnt -= dec_usage_cnt; | 1202 | |
1134 | if (udev->pm_usage_cnt <= 0) | 1203 | status = usb_autopm_do_device(udev, -1); |
1135 | queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, | ||
1136 | USB_AUTOSUSPEND_DELAY); | ||
1137 | usb_pm_unlock(udev); | ||
1138 | // dev_dbg(&udev->dev, "%s: cnt %d\n", | 1204 | // dev_dbg(&udev->dev, "%s: cnt %d\n", |
1139 | // __FUNCTION__, udev->pm_usage_cnt); | 1205 | // __FUNCTION__, udev->pm_usage_cnt); |
1140 | } | 1206 | } |
@@ -1142,44 +1208,59 @@ void usb_autosuspend_device(struct usb_device *udev, int dec_usage_cnt) | |||
1142 | /** | 1208 | /** |
1143 | * usb_autoresume_device - immediately autoresume a USB device and its interfaces | 1209 | * usb_autoresume_device - immediately autoresume a USB device and its interfaces |
1144 | * @udev: the usb_device to autoresume | 1210 | * @udev: the usb_device to autoresume |
1145 | * @inc_usage_cnt: flag to increment @udev's PM-usage counter | ||
1146 | * | 1211 | * |
1147 | * This routine should be called when a core subsystem wants to use @udev | 1212 | * This routine should be called when a core subsystem wants to use @udev |
1148 | * and needs to guarantee that it is not suspended. In addition, the | 1213 | * and needs to guarantee that it is not suspended. No autosuspend will |
1149 | * caller can prevent @udev from being autosuspended subsequently. (Note | 1214 | * occur until usb_autosuspend_device is called. (Note that this will not |
1150 | * that this will not prevent suspend events originating in the PM core.) | 1215 | * prevent suspend events originating in the PM core.) Examples would be |
1151 | * Examples would be when @udev's device file in usbfs is opened (autosuspend | 1216 | * when @udev's device file in usbfs is opened or when a remote-wakeup |
1152 | * should be prevented until the file is closed) or when a remote-wakeup | 1217 | * request is received. |
1153 | * request is received (later autosuspends should not be prevented). | ||
1154 | * | 1218 | * |
1155 | * @inc_usage_cnt should be 1 to increment @udev's usage counter and prevent | 1219 | * @udev's usage counter is incremented to prevent subsequent autosuspends. |
1156 | * autosuspends. This prevention will persist until the usage counter is | 1220 | * However if the autoresume fails then the usage counter is re-decremented. |
1157 | * decremented again (such as by passing 1 to usb_autosuspend_device). | ||
1158 | * Otherwise @inc_usage_cnt should be 0 to leave the usage counter unchanged. | ||
1159 | * Regardless, if the autoresume fails then the usage counter is not | ||
1160 | * incremented. | ||
1161 | * | 1221 | * |
1162 | * Often the caller will hold @udev's device lock, but this is not | 1222 | * Often the caller will hold @udev's device lock, but this is not |
1163 | * necessary (and attempting it might cause deadlock). | 1223 | * necessary (and attempting it might cause deadlock). |
1164 | * | 1224 | * |
1165 | * This routine can run only in process context. | 1225 | * This routine can run only in process context. |
1166 | */ | 1226 | */ |
1167 | int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt) | 1227 | int usb_autoresume_device(struct usb_device *udev) |
1168 | { | 1228 | { |
1169 | int status; | 1229 | int status; |
1170 | 1230 | ||
1171 | usb_pm_lock(udev); | 1231 | status = usb_autopm_do_device(udev, 1); |
1172 | udev->pm_usage_cnt += inc_usage_cnt; | ||
1173 | udev->auto_pm = 1; | ||
1174 | status = usb_resume_both(udev); | ||
1175 | if (status != 0) | ||
1176 | udev->pm_usage_cnt -= inc_usage_cnt; | ||
1177 | usb_pm_unlock(udev); | ||
1178 | // dev_dbg(&udev->dev, "%s: status %d cnt %d\n", | 1232 | // dev_dbg(&udev->dev, "%s: status %d cnt %d\n", |
1179 | // __FUNCTION__, status, udev->pm_usage_cnt); | 1233 | // __FUNCTION__, status, udev->pm_usage_cnt); |
1180 | return status; | 1234 | return status; |
1181 | } | 1235 | } |
1182 | 1236 | ||
1237 | /* Internal routine to adjust an interface's usage counter and change | ||
1238 | * its device's autosuspend state. | ||
1239 | */ | ||
1240 | static int usb_autopm_do_interface(struct usb_interface *intf, | ||
1241 | int inc_usage_cnt) | ||
1242 | { | ||
1243 | struct usb_device *udev = interface_to_usbdev(intf); | ||
1244 | int status = 0; | ||
1245 | |||
1246 | usb_pm_lock(udev); | ||
1247 | if (intf->condition == USB_INTERFACE_UNBOUND) | ||
1248 | status = -ENODEV; | ||
1249 | else { | ||
1250 | intf->pm_usage_cnt += inc_usage_cnt; | ||
1251 | if (inc_usage_cnt >= 0 && intf->pm_usage_cnt > 0) { | ||
1252 | udev->auto_pm = 1; | ||
1253 | status = usb_resume_both(udev); | ||
1254 | if (status != 0) | ||
1255 | intf->pm_usage_cnt -= inc_usage_cnt; | ||
1256 | } else if (inc_usage_cnt <= 0 && autosuspend_check(udev) == 0) | ||
1257 | queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, | ||
1258 | USB_AUTOSUSPEND_DELAY); | ||
1259 | } | ||
1260 | usb_pm_unlock(udev); | ||
1261 | return status; | ||
1262 | } | ||
1263 | |||
1183 | /** | 1264 | /** |
1184 | * usb_autopm_put_interface - decrement a USB interface's PM-usage counter | 1265 | * usb_autopm_put_interface - decrement a USB interface's PM-usage counter |
1185 | * @intf: the usb_interface whose counter should be decremented | 1266 | * @intf: the usb_interface whose counter should be decremented |
@@ -1213,17 +1294,11 @@ int usb_autoresume_device(struct usb_device *udev, int inc_usage_cnt) | |||
1213 | */ | 1294 | */ |
1214 | void usb_autopm_put_interface(struct usb_interface *intf) | 1295 | void usb_autopm_put_interface(struct usb_interface *intf) |
1215 | { | 1296 | { |
1216 | struct usb_device *udev = interface_to_usbdev(intf); | 1297 | int status; |
1217 | 1298 | ||
1218 | usb_pm_lock(udev); | 1299 | status = usb_autopm_do_interface(intf, -1); |
1219 | if (intf->condition != USB_INTERFACE_UNBOUND && | 1300 | // dev_dbg(&intf->dev, "%s: status %d cnt %d\n", |
1220 | --intf->pm_usage_cnt <= 0) { | 1301 | // __FUNCTION__, status, intf->pm_usage_cnt); |
1221 | queue_delayed_work(ksuspend_usb_wq, &udev->autosuspend, | ||
1222 | USB_AUTOSUSPEND_DELAY); | ||
1223 | } | ||
1224 | usb_pm_unlock(udev); | ||
1225 | // dev_dbg(&intf->dev, "%s: cnt %d\n", | ||
1226 | // __FUNCTION__, intf->pm_usage_cnt); | ||
1227 | } | 1302 | } |
1228 | EXPORT_SYMBOL_GPL(usb_autopm_put_interface); | 1303 | EXPORT_SYMBOL_GPL(usb_autopm_put_interface); |
1229 | 1304 | ||
@@ -1260,26 +1335,37 @@ EXPORT_SYMBOL_GPL(usb_autopm_put_interface); | |||
1260 | */ | 1335 | */ |
1261 | int usb_autopm_get_interface(struct usb_interface *intf) | 1336 | int usb_autopm_get_interface(struct usb_interface *intf) |
1262 | { | 1337 | { |
1263 | struct usb_device *udev = interface_to_usbdev(intf); | 1338 | int status; |
1264 | int status; | ||
1265 | 1339 | ||
1266 | usb_pm_lock(udev); | 1340 | status = usb_autopm_do_interface(intf, 1); |
1267 | if (intf->condition == USB_INTERFACE_UNBOUND) | ||
1268 | status = -ENODEV; | ||
1269 | else { | ||
1270 | ++intf->pm_usage_cnt; | ||
1271 | udev->auto_pm = 1; | ||
1272 | status = usb_resume_both(udev); | ||
1273 | if (status != 0) | ||
1274 | --intf->pm_usage_cnt; | ||
1275 | } | ||
1276 | usb_pm_unlock(udev); | ||
1277 | // dev_dbg(&intf->dev, "%s: status %d cnt %d\n", | 1341 | // dev_dbg(&intf->dev, "%s: status %d cnt %d\n", |
1278 | // __FUNCTION__, status, intf->pm_usage_cnt); | 1342 | // __FUNCTION__, status, intf->pm_usage_cnt); |
1279 | return status; | 1343 | return status; |
1280 | } | 1344 | } |
1281 | EXPORT_SYMBOL_GPL(usb_autopm_get_interface); | 1345 | EXPORT_SYMBOL_GPL(usb_autopm_get_interface); |
1282 | 1346 | ||
1347 | /** | ||
1348 | * usb_autopm_set_interface - set a USB interface's autosuspend state | ||
1349 | * @intf: the usb_interface whose state should be set | ||
1350 | * | ||
1351 | * This routine sets the autosuspend state of @intf's device according | ||
1352 | * to @intf's usage counter, which the caller must have set previously. | ||
1353 | * If the counter is <= 0, the device is autosuspended (if it isn't | ||
1354 | * already suspended and if nothing else prevents the autosuspend). If | ||
1355 | * the counter is > 0, the device is autoresumed (if it isn't already | ||
1356 | * awake). | ||
1357 | */ | ||
1358 | int usb_autopm_set_interface(struct usb_interface *intf) | ||
1359 | { | ||
1360 | int status; | ||
1361 | |||
1362 | status = usb_autopm_do_interface(intf, 0); | ||
1363 | // dev_dbg(&intf->dev, "%s: status %d cnt %d\n", | ||
1364 | // __FUNCTION__, status, intf->pm_usage_cnt); | ||
1365 | return status; | ||
1366 | } | ||
1367 | EXPORT_SYMBOL_GPL(usb_autopm_set_interface); | ||
1368 | |||
1283 | #endif /* CONFIG_USB_SUSPEND */ | 1369 | #endif /* CONFIG_USB_SUSPEND */ |
1284 | 1370 | ||
1285 | static int usb_suspend(struct device *dev, pm_message_t message) | 1371 | static int usb_suspend(struct device *dev, pm_message_t message) |
diff --git a/drivers/usb/core/endpoint.c b/drivers/usb/core/endpoint.c index 3ebb90149e93..c505b767cee1 100644 --- a/drivers/usb/core/endpoint.c +++ b/drivers/usb/core/endpoint.c | |||
@@ -10,15 +10,20 @@ | |||
10 | */ | 10 | */ |
11 | 11 | ||
12 | #include <linux/kernel.h> | 12 | #include <linux/kernel.h> |
13 | #include <linux/spinlock.h> | ||
14 | #include <linux/idr.h> | ||
13 | #include <linux/usb.h> | 15 | #include <linux/usb.h> |
14 | #include "usb.h" | 16 | #include "usb.h" |
15 | 17 | ||
16 | /* endpoint stuff */ | 18 | #define MAX_ENDPOINT_MINORS (64*128*32) |
19 | static int usb_endpoint_major; | ||
20 | static DEFINE_IDR(endpoint_idr); | ||
17 | 21 | ||
18 | struct ep_device { | 22 | struct ep_device { |
19 | struct usb_endpoint_descriptor *desc; | 23 | struct usb_endpoint_descriptor *desc; |
20 | struct usb_device *udev; | 24 | struct usb_device *udev; |
21 | struct device dev; | 25 | struct device dev; |
26 | int minor; | ||
22 | }; | 27 | }; |
23 | #define to_ep_device(_dev) \ | 28 | #define to_ep_device(_dev) \ |
24 | container_of(_dev, struct ep_device, dev) | 29 | container_of(_dev, struct ep_device, dev) |
@@ -152,6 +157,55 @@ static struct attribute_group ep_dev_attr_grp = { | |||
152 | .attrs = ep_dev_attrs, | 157 | .attrs = ep_dev_attrs, |
153 | }; | 158 | }; |
154 | 159 | ||
160 | static int usb_endpoint_major_init(void) | ||
161 | { | ||
162 | dev_t dev; | ||
163 | int error; | ||
164 | |||
165 | error = alloc_chrdev_region(&dev, 0, MAX_ENDPOINT_MINORS, | ||
166 | "usb_endpoint"); | ||
167 | if (error) { | ||
168 | err("unable to get a dynamic major for usb endpoints"); | ||
169 | return error; | ||
170 | } | ||
171 | usb_endpoint_major = MAJOR(dev); | ||
172 | |||
173 | return error; | ||
174 | } | ||
175 | |||
176 | static void usb_endpoint_major_cleanup(void) | ||
177 | { | ||
178 | unregister_chrdev_region(MKDEV(usb_endpoint_major, 0), | ||
179 | MAX_ENDPOINT_MINORS); | ||
180 | } | ||
181 | |||
182 | static int endpoint_get_minor(struct ep_device *ep_dev) | ||
183 | { | ||
184 | static DEFINE_MUTEX(minor_lock); | ||
185 | int retval = -ENOMEM; | ||
186 | int id; | ||
187 | |||
188 | mutex_lock(&minor_lock); | ||
189 | if (idr_pre_get(&endpoint_idr, GFP_KERNEL) == 0) | ||
190 | goto exit; | ||
191 | |||
192 | retval = idr_get_new(&endpoint_idr, ep_dev, &id); | ||
193 | if (retval < 0) { | ||
194 | if (retval == -EAGAIN) | ||
195 | retval = -ENOMEM; | ||
196 | goto exit; | ||
197 | } | ||
198 | ep_dev->minor = id & MAX_ID_MASK; | ||
199 | exit: | ||
200 | mutex_unlock(&minor_lock); | ||
201 | return retval; | ||
202 | } | ||
203 | |||
204 | static void endpoint_free_minor(struct ep_device *ep_dev) | ||
205 | { | ||
206 | idr_remove(&endpoint_idr, ep_dev->minor); | ||
207 | } | ||
208 | |||
155 | static struct endpoint_class { | 209 | static struct endpoint_class { |
156 | struct kref kref; | 210 | struct kref kref; |
157 | struct class *class; | 211 | struct class *class; |
@@ -176,11 +230,20 @@ static int init_endpoint_class(void) | |||
176 | ep_class->class = class_create(THIS_MODULE, "usb_endpoint"); | 230 | ep_class->class = class_create(THIS_MODULE, "usb_endpoint"); |
177 | if (IS_ERR(ep_class->class)) { | 231 | if (IS_ERR(ep_class->class)) { |
178 | result = IS_ERR(ep_class->class); | 232 | result = IS_ERR(ep_class->class); |
179 | kfree(ep_class); | 233 | goto class_create_error; |
180 | ep_class = NULL; | ||
181 | goto exit; | ||
182 | } | 234 | } |
183 | 235 | ||
236 | result = usb_endpoint_major_init(); | ||
237 | if (result) | ||
238 | goto endpoint_major_error; | ||
239 | |||
240 | goto exit; | ||
241 | |||
242 | endpoint_major_error: | ||
243 | class_destroy(ep_class->class); | ||
244 | class_create_error: | ||
245 | kfree(ep_class); | ||
246 | ep_class = NULL; | ||
184 | exit: | 247 | exit: |
185 | return result; | 248 | return result; |
186 | } | 249 | } |
@@ -191,6 +254,7 @@ static void release_endpoint_class(struct kref *kref) | |||
191 | class_destroy(ep_class->class); | 254 | class_destroy(ep_class->class); |
192 | kfree(ep_class); | 255 | kfree(ep_class); |
193 | ep_class = NULL; | 256 | ep_class = NULL; |
257 | usb_endpoint_major_cleanup(); | ||
194 | } | 258 | } |
195 | 259 | ||
196 | static void destroy_endpoint_class(void) | 260 | static void destroy_endpoint_class(void) |
@@ -213,7 +277,6 @@ int usb_create_ep_files(struct device *parent, | |||
213 | { | 277 | { |
214 | char name[8]; | 278 | char name[8]; |
215 | struct ep_device *ep_dev; | 279 | struct ep_device *ep_dev; |
216 | int minor; | ||
217 | int retval; | 280 | int retval; |
218 | 281 | ||
219 | retval = init_endpoint_class(); | 282 | retval = init_endpoint_class(); |
@@ -223,15 +286,19 @@ int usb_create_ep_files(struct device *parent, | |||
223 | ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); | 286 | ep_dev = kzalloc(sizeof(*ep_dev), GFP_KERNEL); |
224 | if (!ep_dev) { | 287 | if (!ep_dev) { |
225 | retval = -ENOMEM; | 288 | retval = -ENOMEM; |
226 | goto exit; | 289 | goto error_alloc; |
227 | } | 290 | } |
228 | 291 | ||
229 | /* fun calculation to determine the minor of this endpoint */ | 292 | retval = endpoint_get_minor(ep_dev); |
230 | minor = (((udev->bus->busnum - 1) * 128) * 16) + (udev->devnum - 1); | 293 | if (retval) { |
294 | dev_err(parent, "can not allocate minor number for %s", | ||
295 | ep_dev->dev.bus_id); | ||
296 | goto error_register; | ||
297 | } | ||
231 | 298 | ||
232 | ep_dev->desc = &endpoint->desc; | 299 | ep_dev->desc = &endpoint->desc; |
233 | ep_dev->udev = udev; | 300 | ep_dev->udev = udev; |
234 | ep_dev->dev.devt = MKDEV(442, minor); // FIXME fake number... | 301 | ep_dev->dev.devt = MKDEV(usb_endpoint_major, ep_dev->minor); |
235 | ep_dev->dev.class = ep_class->class; | 302 | ep_dev->dev.class = ep_class->class; |
236 | ep_dev->dev.parent = parent; | 303 | ep_dev->dev.parent = parent; |
237 | ep_dev->dev.release = ep_device_release; | 304 | ep_dev->dev.release = ep_device_release; |
@@ -241,49 +308,50 @@ int usb_create_ep_files(struct device *parent, | |||
241 | 308 | ||
242 | retval = device_register(&ep_dev->dev); | 309 | retval = device_register(&ep_dev->dev); |
243 | if (retval) | 310 | if (retval) |
244 | goto error; | 311 | goto error_chrdev; |
245 | retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); | 312 | retval = sysfs_create_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); |
246 | if (retval) | 313 | if (retval) |
247 | goto error_group; | 314 | goto error_group; |
248 | 315 | ||
249 | endpoint->ep_dev = ep_dev; | ||
250 | |||
251 | /* create the symlink to the old-style "ep_XX" directory */ | 316 | /* create the symlink to the old-style "ep_XX" directory */ |
252 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); | 317 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); |
253 | retval = sysfs_create_link(&parent->kobj, | 318 | retval = sysfs_create_link(&parent->kobj, &ep_dev->dev.kobj, name); |
254 | &endpoint->ep_dev->dev.kobj, name); | ||
255 | if (retval) | 319 | if (retval) |
256 | goto error_link; | 320 | goto error_link; |
257 | exit: | 321 | endpoint->ep_dev = ep_dev; |
258 | return retval; | 322 | return retval; |
259 | 323 | ||
260 | error_link: | 324 | error_link: |
261 | sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); | 325 | sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); |
262 | |||
263 | error_group: | 326 | error_group: |
264 | device_unregister(&ep_dev->dev); | 327 | device_unregister(&ep_dev->dev); |
265 | endpoint->ep_dev = NULL; | ||
266 | destroy_endpoint_class(); | 328 | destroy_endpoint_class(); |
267 | return retval; | 329 | return retval; |
268 | error: | 330 | |
331 | error_chrdev: | ||
332 | endpoint_free_minor(ep_dev); | ||
333 | |||
334 | error_register: | ||
269 | kfree(ep_dev); | 335 | kfree(ep_dev); |
336 | error_alloc: | ||
270 | destroy_endpoint_class(); | 337 | destroy_endpoint_class(); |
338 | exit: | ||
271 | return retval; | 339 | return retval; |
272 | } | 340 | } |
273 | 341 | ||
274 | void usb_remove_ep_files(struct usb_host_endpoint *endpoint) | 342 | void usb_remove_ep_files(struct usb_host_endpoint *endpoint) |
275 | { | 343 | { |
344 | struct ep_device *ep_dev = endpoint->ep_dev; | ||
276 | 345 | ||
277 | if (endpoint->ep_dev) { | 346 | if (ep_dev) { |
278 | char name[8]; | 347 | char name[8]; |
279 | 348 | ||
280 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); | 349 | sprintf(name, "ep_%02x", endpoint->desc.bEndpointAddress); |
281 | sysfs_remove_link(&endpoint->ep_dev->dev.parent->kobj, name); | 350 | sysfs_remove_link(&ep_dev->dev.parent->kobj, name); |
282 | sysfs_remove_group(&endpoint->ep_dev->dev.kobj, &ep_dev_attr_grp); | 351 | sysfs_remove_group(&ep_dev->dev.kobj, &ep_dev_attr_grp); |
283 | device_unregister(&endpoint->ep_dev->dev); | 352 | endpoint_free_minor(ep_dev); |
353 | device_unregister(&ep_dev->dev); | ||
284 | endpoint->ep_dev = NULL; | 354 | endpoint->ep_dev = NULL; |
355 | destroy_endpoint_class(); | ||
285 | } | 356 | } |
286 | destroy_endpoint_class(); | ||
287 | } | 357 | } |
288 | |||
289 | |||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index afa2dd203329..10064af65d17 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -256,7 +256,9 @@ static const u8 hs_rh_config_descriptor [] = { | |||
256 | 0x05, /* __u8 ep_bDescriptorType; Endpoint */ | 256 | 0x05, /* __u8 ep_bDescriptorType; Endpoint */ |
257 | 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ | 257 | 0x81, /* __u8 ep_bEndpointAddress; IN Endpoint 1 */ |
258 | 0x03, /* __u8 ep_bmAttributes; Interrupt */ | 258 | 0x03, /* __u8 ep_bmAttributes; Interrupt */ |
259 | 0x02, 0x00, /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) */ | 259 | /* __le16 ep_wMaxPacketSize; 1 + (MAX_ROOT_PORTS / 8) |
260 | * see hub.c:hub_configure() for details. */ | ||
261 | (USB_MAXCHILDREN + 1 + 7) / 8, 0x00, | ||
260 | 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */ | 262 | 0x0c /* __u8 ep_bInterval; (256ms -- usb 2.0 spec) */ |
261 | }; | 263 | }; |
262 | 264 | ||
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 66bff184a30c..0ce393eb3c4b 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -31,6 +31,47 @@ | |||
31 | #include "hcd.h" | 31 | #include "hcd.h" |
32 | #include "hub.h" | 32 | #include "hub.h" |
33 | 33 | ||
34 | struct usb_hub { | ||
35 | struct device *intfdev; /* the "interface" device */ | ||
36 | struct usb_device *hdev; | ||
37 | struct urb *urb; /* for interrupt polling pipe */ | ||
38 | |||
39 | /* buffer for urb ... with extra space in case of babble */ | ||
40 | char (*buffer)[8]; | ||
41 | dma_addr_t buffer_dma; /* DMA address for buffer */ | ||
42 | union { | ||
43 | struct usb_hub_status hub; | ||
44 | struct usb_port_status port; | ||
45 | } *status; /* buffer for status reports */ | ||
46 | |||
47 | int error; /* last reported error */ | ||
48 | int nerrors; /* track consecutive errors */ | ||
49 | |||
50 | struct list_head event_list; /* hubs w/data or errs ready */ | ||
51 | unsigned long event_bits[1]; /* status change bitmask */ | ||
52 | unsigned long change_bits[1]; /* ports with logical connect | ||
53 | status change */ | ||
54 | unsigned long busy_bits[1]; /* ports being reset or | ||
55 | resumed */ | ||
56 | #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ | ||
57 | #error event_bits[] is too short! | ||
58 | #endif | ||
59 | |||
60 | struct usb_hub_descriptor *descriptor; /* class descriptor */ | ||
61 | struct usb_tt tt; /* Transaction Translator */ | ||
62 | |||
63 | unsigned mA_per_port; /* current for each child */ | ||
64 | |||
65 | unsigned limited_power:1; | ||
66 | unsigned quiescing:1; | ||
67 | unsigned activating:1; | ||
68 | |||
69 | unsigned has_indicators:1; | ||
70 | u8 indicator[USB_MAXCHILDREN]; | ||
71 | struct work_struct leds; | ||
72 | }; | ||
73 | |||
74 | |||
34 | /* Protect struct usb_device->state and ->children members | 75 | /* Protect struct usb_device->state and ->children members |
35 | * Note: Both are also protected by ->dev.sem, except that ->state can | 76 | * Note: Both are also protected by ->dev.sem, except that ->state can |
36 | * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ | 77 | * change to USB_STATE_NOTATTACHED even when the semaphore isn't held. */ |
@@ -45,6 +86,16 @@ static DECLARE_WAIT_QUEUE_HEAD(khubd_wait); | |||
45 | 86 | ||
46 | static struct task_struct *khubd_task; | 87 | static struct task_struct *khubd_task; |
47 | 88 | ||
89 | /* multithreaded probe logic */ | ||
90 | static int multithread_probe = | ||
91 | #ifdef CONFIG_USB_MULTITHREAD_PROBE | ||
92 | 1; | ||
93 | #else | ||
94 | 0; | ||
95 | #endif | ||
96 | module_param(multithread_probe, bool, S_IRUGO); | ||
97 | MODULE_PARM_DESC(multithread_probe, "Run each USB device probe in a new thread"); | ||
98 | |||
48 | /* cycle leds on hubs that aren't blinking for attention */ | 99 | /* cycle leds on hubs that aren't blinking for attention */ |
49 | static int blinkenlights = 0; | 100 | static int blinkenlights = 0; |
50 | module_param (blinkenlights, bool, S_IRUGO); | 101 | module_param (blinkenlights, bool, S_IRUGO); |
@@ -276,6 +327,9 @@ static void kick_khubd(struct usb_hub *hub) | |||
276 | { | 327 | { |
277 | unsigned long flags; | 328 | unsigned long flags; |
278 | 329 | ||
330 | /* Suppress autosuspend until khubd runs */ | ||
331 | to_usb_interface(hub->intfdev)->pm_usage_cnt = 1; | ||
332 | |||
279 | spin_lock_irqsave(&hub_event_lock, flags); | 333 | spin_lock_irqsave(&hub_event_lock, flags); |
280 | if (list_empty(&hub->event_list)) { | 334 | if (list_empty(&hub->event_list)) { |
281 | list_add_tail(&hub->event_list, &hub_event_list); | 335 | list_add_tail(&hub->event_list, &hub_event_list); |
@@ -457,7 +511,6 @@ static void hub_quiesce(struct usb_hub *hub) | |||
457 | /* (nonblocking) khubd and related activity won't re-trigger */ | 511 | /* (nonblocking) khubd and related activity won't re-trigger */ |
458 | hub->quiescing = 1; | 512 | hub->quiescing = 1; |
459 | hub->activating = 0; | 513 | hub->activating = 0; |
460 | hub->resume_root_hub = 0; | ||
461 | 514 | ||
462 | /* (blocking) stop khubd and related activity */ | 515 | /* (blocking) stop khubd and related activity */ |
463 | usb_kill_urb(hub->urb); | 516 | usb_kill_urb(hub->urb); |
@@ -473,7 +526,7 @@ static void hub_activate(struct usb_hub *hub) | |||
473 | 526 | ||
474 | hub->quiescing = 0; | 527 | hub->quiescing = 0; |
475 | hub->activating = 1; | 528 | hub->activating = 1; |
476 | hub->resume_root_hub = 0; | 529 | |
477 | status = usb_submit_urb(hub->urb, GFP_NOIO); | 530 | status = usb_submit_urb(hub->urb, GFP_NOIO); |
478 | if (status < 0) | 531 | if (status < 0) |
479 | dev_err(hub->intfdev, "activate --> %d\n", status); | 532 | dev_err(hub->intfdev, "activate --> %d\n", status); |
@@ -759,7 +812,12 @@ static int hub_configure(struct usb_hub *hub, | |||
759 | dev_dbg(hub_dev, "%sover-current condition exists\n", | 812 | dev_dbg(hub_dev, "%sover-current condition exists\n", |
760 | (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); | 813 | (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); |
761 | 814 | ||
762 | /* set up the interrupt endpoint */ | 815 | /* set up the interrupt endpoint |
816 | * We use the EP's maxpacket size instead of (PORTS+1+7)/8 | ||
817 | * bytes as USB2.0[11.12.3] says because some hubs are known | ||
818 | * to send more data (and thus cause overflow). For root hubs, | ||
819 | * maxpktsize is defined in hcd.c's fake endpoint descriptors | ||
820 | * to be big enough for at least USB_MAXCHILDREN ports. */ | ||
763 | pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); | 821 | pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); |
764 | maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); | 822 | maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); |
765 | 823 | ||
@@ -883,6 +941,7 @@ descriptor_error: | |||
883 | INIT_WORK(&hub->leds, led_work, hub); | 941 | INIT_WORK(&hub->leds, led_work, hub); |
884 | 942 | ||
885 | usb_set_intfdata (intf, hub); | 943 | usb_set_intfdata (intf, hub); |
944 | intf->needs_remote_wakeup = 1; | ||
886 | 945 | ||
887 | if (hdev->speed == USB_SPEED_HIGH) | 946 | if (hdev->speed == USB_SPEED_HIGH) |
888 | highspeed_hubs++; | 947 | highspeed_hubs++; |
@@ -980,6 +1039,8 @@ static void recursively_mark_NOTATTACHED(struct usb_device *udev) | |||
980 | if (udev->children[i]) | 1039 | if (udev->children[i]) |
981 | recursively_mark_NOTATTACHED(udev->children[i]); | 1040 | recursively_mark_NOTATTACHED(udev->children[i]); |
982 | } | 1041 | } |
1042 | if (udev->state == USB_STATE_SUSPENDED) | ||
1043 | udev->discon_suspended = 1; | ||
983 | udev->state = USB_STATE_NOTATTACHED; | 1044 | udev->state = USB_STATE_NOTATTACHED; |
984 | } | 1045 | } |
985 | 1046 | ||
@@ -1169,6 +1230,14 @@ void usb_disconnect(struct usb_device **pdev) | |||
1169 | *pdev = NULL; | 1230 | *pdev = NULL; |
1170 | spin_unlock_irq(&device_state_lock); | 1231 | spin_unlock_irq(&device_state_lock); |
1171 | 1232 | ||
1233 | /* Decrement the parent's count of unsuspended children */ | ||
1234 | if (udev->parent) { | ||
1235 | usb_pm_lock(udev); | ||
1236 | if (!udev->discon_suspended) | ||
1237 | usb_autosuspend_device(udev->parent); | ||
1238 | usb_pm_unlock(udev); | ||
1239 | } | ||
1240 | |||
1172 | put_device(&udev->dev); | 1241 | put_device(&udev->dev); |
1173 | } | 1242 | } |
1174 | 1243 | ||
@@ -1188,31 +1257,20 @@ static inline void show_string(struct usb_device *udev, char *id, char *string) | |||
1188 | 1257 | ||
1189 | #ifdef CONFIG_USB_OTG | 1258 | #ifdef CONFIG_USB_OTG |
1190 | #include "otg_whitelist.h" | 1259 | #include "otg_whitelist.h" |
1260 | static int __usb_port_suspend(struct usb_device *, int port1); | ||
1191 | #endif | 1261 | #endif |
1192 | 1262 | ||
1193 | /** | 1263 | static int __usb_new_device(void *void_data) |
1194 | * usb_new_device - perform initial device setup (usbcore-internal) | ||
1195 | * @udev: newly addressed device (in ADDRESS state) | ||
1196 | * | ||
1197 | * This is called with devices which have been enumerated, but not yet | ||
1198 | * configured. The device descriptor is available, but not descriptors | ||
1199 | * for any device configuration. The caller must have locked either | ||
1200 | * the parent hub (if udev is a normal device) or else the | ||
1201 | * usb_bus_list_lock (if udev is a root hub). The parent's pointer to | ||
1202 | * udev has already been installed, but udev is not yet visible through | ||
1203 | * sysfs or other filesystem code. | ||
1204 | * | ||
1205 | * Returns 0 for success (device is configured and listed, with its | ||
1206 | * interfaces, in sysfs); else a negative errno value. | ||
1207 | * | ||
1208 | * This call is synchronous, and may not be used in an interrupt context. | ||
1209 | * | ||
1210 | * Only the hub driver or root-hub registrar should ever call this. | ||
1211 | */ | ||
1212 | int usb_new_device(struct usb_device *udev) | ||
1213 | { | 1264 | { |
1265 | struct usb_device *udev = void_data; | ||
1214 | int err; | 1266 | int err; |
1215 | 1267 | ||
1268 | /* Lock ourself into memory in order to keep a probe sequence | ||
1269 | * sleeping in a new thread from allowing us to be unloaded. | ||
1270 | */ | ||
1271 | if (!try_module_get(THIS_MODULE)) | ||
1272 | return -EINVAL; | ||
1273 | |||
1216 | err = usb_get_configuration(udev); | 1274 | err = usb_get_configuration(udev); |
1217 | if (err < 0) { | 1275 | if (err < 0) { |
1218 | dev_err(&udev->dev, "can't read configurations, error %d\n", | 1276 | dev_err(&udev->dev, "can't read configurations, error %d\n", |
@@ -1289,8 +1347,6 @@ int usb_new_device(struct usb_device *udev) | |||
1289 | * (Includes HNP test device.) | 1347 | * (Includes HNP test device.) |
1290 | */ | 1348 | */ |
1291 | if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { | 1349 | if (udev->bus->b_hnp_enable || udev->bus->is_b_host) { |
1292 | static int __usb_port_suspend(struct usb_device *, | ||
1293 | int port1); | ||
1294 | err = __usb_port_suspend(udev, udev->bus->otg_port); | 1350 | err = __usb_port_suspend(udev, udev->bus->otg_port); |
1295 | if (err < 0) | 1351 | if (err < 0) |
1296 | dev_dbg(&udev->dev, "HNP fail, %d\n", err); | 1352 | dev_dbg(&udev->dev, "HNP fail, %d\n", err); |
@@ -1310,13 +1366,56 @@ int usb_new_device(struct usb_device *udev) | |||
1310 | goto fail; | 1366 | goto fail; |
1311 | } | 1367 | } |
1312 | 1368 | ||
1313 | return 0; | 1369 | /* Increment the parent's count of unsuspended children */ |
1370 | if (udev->parent) | ||
1371 | usb_autoresume_device(udev->parent); | ||
1372 | |||
1373 | exit: | ||
1374 | module_put(THIS_MODULE); | ||
1375 | return err; | ||
1314 | 1376 | ||
1315 | fail: | 1377 | fail: |
1316 | usb_set_device_state(udev, USB_STATE_NOTATTACHED); | 1378 | usb_set_device_state(udev, USB_STATE_NOTATTACHED); |
1317 | return err; | 1379 | goto exit; |
1318 | } | 1380 | } |
1319 | 1381 | ||
1382 | /** | ||
1383 | * usb_new_device - perform initial device setup (usbcore-internal) | ||
1384 | * @udev: newly addressed device (in ADDRESS state) | ||
1385 | * | ||
1386 | * This is called with devices which have been enumerated, but not yet | ||
1387 | * configured. The device descriptor is available, but not descriptors | ||
1388 | * for any device configuration. The caller must have locked either | ||
1389 | * the parent hub (if udev is a normal device) or else the | ||
1390 | * usb_bus_list_lock (if udev is a root hub). The parent's pointer to | ||
1391 | * udev has already been installed, but udev is not yet visible through | ||
1392 | * sysfs or other filesystem code. | ||
1393 | * | ||
1394 | * The return value for this function depends on if the | ||
1395 | * multithread_probe variable is set or not. If it's set, it will | ||
1396 | * return a if the probe thread was successfully created or not. If the | ||
1397 | * variable is not set, it will return if the device is configured | ||
1398 | * properly or not. interfaces, in sysfs); else a negative errno value. | ||
1399 | * | ||
1400 | * This call is synchronous, and may not be used in an interrupt context. | ||
1401 | * | ||
1402 | * Only the hub driver or root-hub registrar should ever call this. | ||
1403 | */ | ||
1404 | int usb_new_device(struct usb_device *udev) | ||
1405 | { | ||
1406 | struct task_struct *probe_task; | ||
1407 | int ret = 0; | ||
1408 | |||
1409 | if (multithread_probe) { | ||
1410 | probe_task = kthread_run(__usb_new_device, udev, | ||
1411 | "usb-probe-%s", udev->devnum); | ||
1412 | if (IS_ERR(probe_task)) | ||
1413 | ret = PTR_ERR(probe_task); | ||
1414 | } else | ||
1415 | ret = __usb_new_device(udev); | ||
1416 | |||
1417 | return ret; | ||
1418 | } | ||
1320 | 1419 | ||
1321 | static int hub_port_status(struct usb_hub *hub, int port1, | 1420 | static int hub_port_status(struct usb_hub *hub, int port1, |
1322 | u16 *status, u16 *change) | 1421 | u16 *status, u16 *change) |
@@ -1324,10 +1423,12 @@ static int hub_port_status(struct usb_hub *hub, int port1, | |||
1324 | int ret; | 1423 | int ret; |
1325 | 1424 | ||
1326 | ret = get_port_status(hub->hdev, port1, &hub->status->port); | 1425 | ret = get_port_status(hub->hdev, port1, &hub->status->port); |
1327 | if (ret < 0) | 1426 | if (ret < 4) { |
1328 | dev_err (hub->intfdev, | 1427 | dev_err (hub->intfdev, |
1329 | "%s failed (err = %d)\n", __FUNCTION__, ret); | 1428 | "%s failed (err = %d)\n", __FUNCTION__, ret); |
1330 | else { | 1429 | if (ret >= 0) |
1430 | ret = -EIO; | ||
1431 | } else { | ||
1331 | *status = le16_to_cpu(hub->status->port.wPortStatus); | 1432 | *status = le16_to_cpu(hub->status->port.wPortStatus); |
1332 | *change = le16_to_cpu(hub->status->port.wPortChange); | 1433 | *change = le16_to_cpu(hub->status->port.wPortChange); |
1333 | ret = 0; | 1434 | ret = 0; |
@@ -1675,6 +1776,12 @@ static int | |||
1675 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | 1776 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) |
1676 | { | 1777 | { |
1677 | int status; | 1778 | int status; |
1779 | u16 portchange, portstatus; | ||
1780 | |||
1781 | /* Skip the initial Clear-Suspend step for a remote wakeup */ | ||
1782 | status = hub_port_status(hub, port1, &portstatus, &portchange); | ||
1783 | if (status == 0 && !(portstatus & USB_PORT_STAT_SUSPEND)) | ||
1784 | goto SuspendCleared; | ||
1678 | 1785 | ||
1679 | // dev_dbg(hub->intfdev, "resume port %d\n", port1); | 1786 | // dev_dbg(hub->intfdev, "resume port %d\n", port1); |
1680 | 1787 | ||
@@ -1688,9 +1795,6 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | |||
1688 | "can't resume port %d, status %d\n", | 1795 | "can't resume port %d, status %d\n", |
1689 | port1, status); | 1796 | port1, status); |
1690 | } else { | 1797 | } else { |
1691 | u16 devstatus; | ||
1692 | u16 portchange; | ||
1693 | |||
1694 | /* drive resume for at least 20 msec */ | 1798 | /* drive resume for at least 20 msec */ |
1695 | if (udev) | 1799 | if (udev) |
1696 | dev_dbg(&udev->dev, "usb %sresume\n", | 1800 | dev_dbg(&udev->dev, "usb %sresume\n", |
@@ -1705,16 +1809,15 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | |||
1705 | * stop resume signaling. Then finish the resume | 1809 | * stop resume signaling. Then finish the resume |
1706 | * sequence. | 1810 | * sequence. |
1707 | */ | 1811 | */ |
1708 | devstatus = portchange = 0; | 1812 | status = hub_port_status(hub, port1, &portstatus, &portchange); |
1709 | status = hub_port_status(hub, port1, | 1813 | SuspendCleared: |
1710 | &devstatus, &portchange); | ||
1711 | if (status < 0 | 1814 | if (status < 0 |
1712 | || (devstatus & LIVE_FLAGS) != LIVE_FLAGS | 1815 | || (portstatus & LIVE_FLAGS) != LIVE_FLAGS |
1713 | || (devstatus & USB_PORT_STAT_SUSPEND) != 0 | 1816 | || (portstatus & USB_PORT_STAT_SUSPEND) != 0 |
1714 | ) { | 1817 | ) { |
1715 | dev_dbg(hub->intfdev, | 1818 | dev_dbg(hub->intfdev, |
1716 | "port %d status %04x.%04x after resume, %d\n", | 1819 | "port %d status %04x.%04x after resume, %d\n", |
1717 | port1, portchange, devstatus, status); | 1820 | port1, portchange, portstatus, status); |
1718 | if (status >= 0) | 1821 | if (status >= 0) |
1719 | status = -ENODEV; | 1822 | status = -ENODEV; |
1720 | } else { | 1823 | } else { |
@@ -1775,23 +1878,16 @@ static int remote_wakeup(struct usb_device *udev) | |||
1775 | { | 1878 | { |
1776 | int status = 0; | 1879 | int status = 0; |
1777 | 1880 | ||
1778 | /* All this just to avoid sending a port-resume message | ||
1779 | * to the parent hub! */ | ||
1780 | |||
1781 | usb_lock_device(udev); | 1881 | usb_lock_device(udev); |
1782 | usb_pm_lock(udev); | ||
1783 | if (udev->state == USB_STATE_SUSPENDED) { | 1882 | if (udev->state == USB_STATE_SUSPENDED) { |
1784 | dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); | 1883 | dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); |
1785 | /* TRSMRCY = 10 msec */ | 1884 | status = usb_autoresume_device(udev); |
1786 | msleep(10); | 1885 | |
1787 | status = finish_port_resume(udev); | 1886 | /* Give the interface drivers a chance to do something, |
1887 | * then autosuspend the device again. */ | ||
1788 | if (status == 0) | 1888 | if (status == 0) |
1789 | udev->dev.power.power_state.event = PM_EVENT_ON; | 1889 | usb_autosuspend_device(udev); |
1790 | } | 1890 | } |
1791 | usb_pm_unlock(udev); | ||
1792 | |||
1793 | if (status == 0) | ||
1794 | usb_autoresume_device(udev, 0); | ||
1795 | usb_unlock_device(udev); | 1891 | usb_unlock_device(udev); |
1796 | return status; | 1892 | return status; |
1797 | } | 1893 | } |
@@ -1855,6 +1951,8 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
1855 | } | 1951 | } |
1856 | } | 1952 | } |
1857 | 1953 | ||
1954 | dev_dbg(&intf->dev, "%s\n", __FUNCTION__); | ||
1955 | |||
1858 | /* "global suspend" of the downstream HC-to-USB interface */ | 1956 | /* "global suspend" of the downstream HC-to-USB interface */ |
1859 | if (!hdev->parent) { | 1957 | if (!hdev->parent) { |
1860 | struct usb_bus *bus = hdev->bus; | 1958 | struct usb_bus *bus = hdev->bus; |
@@ -1877,10 +1975,12 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
1877 | 1975 | ||
1878 | static int hub_resume(struct usb_interface *intf) | 1976 | static int hub_resume(struct usb_interface *intf) |
1879 | { | 1977 | { |
1880 | struct usb_device *hdev = interface_to_usbdev(intf); | ||
1881 | struct usb_hub *hub = usb_get_intfdata (intf); | 1978 | struct usb_hub *hub = usb_get_intfdata (intf); |
1979 | struct usb_device *hdev = hub->hdev; | ||
1882 | int status; | 1980 | int status; |
1883 | 1981 | ||
1982 | dev_dbg(&intf->dev, "%s\n", __FUNCTION__); | ||
1983 | |||
1884 | /* "global resume" of the downstream HC-to-USB interface */ | 1984 | /* "global resume" of the downstream HC-to-USB interface */ |
1885 | if (!hdev->parent) { | 1985 | if (!hdev->parent) { |
1886 | struct usb_bus *bus = hdev->bus; | 1986 | struct usb_bus *bus = hdev->bus; |
@@ -1919,7 +2019,6 @@ void usb_resume_root_hub(struct usb_device *hdev) | |||
1919 | { | 2019 | { |
1920 | struct usb_hub *hub = hdev_to_hub(hdev); | 2020 | struct usb_hub *hub = hdev_to_hub(hdev); |
1921 | 2021 | ||
1922 | hub->resume_root_hub = 1; | ||
1923 | kick_khubd(hub); | 2022 | kick_khubd(hub); |
1924 | } | 2023 | } |
1925 | 2024 | ||
@@ -2556,16 +2655,13 @@ static void hub_events(void) | |||
2556 | intf = to_usb_interface(hub->intfdev); | 2655 | intf = to_usb_interface(hub->intfdev); |
2557 | hub_dev = &intf->dev; | 2656 | hub_dev = &intf->dev; |
2558 | 2657 | ||
2559 | i = hub->resume_root_hub; | 2658 | dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", |
2560 | |||
2561 | dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x%s\n", | ||
2562 | hdev->state, hub->descriptor | 2659 | hdev->state, hub->descriptor |
2563 | ? hub->descriptor->bNbrPorts | 2660 | ? hub->descriptor->bNbrPorts |
2564 | : 0, | 2661 | : 0, |
2565 | /* NOTE: expects max 15 ports... */ | 2662 | /* NOTE: expects max 15 ports... */ |
2566 | (u16) hub->change_bits[0], | 2663 | (u16) hub->change_bits[0], |
2567 | (u16) hub->event_bits[0], | 2664 | (u16) hub->event_bits[0]); |
2568 | i ? ", resume root" : ""); | ||
2569 | 2665 | ||
2570 | usb_get_intf(intf); | 2666 | usb_get_intf(intf); |
2571 | spin_unlock_irq(&hub_event_lock); | 2667 | spin_unlock_irq(&hub_event_lock); |
@@ -2586,16 +2682,16 @@ static void hub_events(void) | |||
2586 | goto loop; | 2682 | goto loop; |
2587 | } | 2683 | } |
2588 | 2684 | ||
2589 | /* Is this is a root hub wanting to reactivate the downstream | 2685 | /* Autoresume */ |
2590 | * ports? If so, be sure the interface resumes even if its | 2686 | ret = usb_autopm_get_interface(intf); |
2591 | * stub "device" node was never suspended. | 2687 | if (ret) { |
2592 | */ | 2688 | dev_dbg(hub_dev, "Can't autoresume: %d\n", ret); |
2593 | if (i) | 2689 | goto loop; |
2594 | usb_autoresume_device(hdev, 0); | 2690 | } |
2595 | 2691 | ||
2596 | /* If this is an inactive or suspended hub, do nothing */ | 2692 | /* If this is an inactive hub, do nothing */ |
2597 | if (hub->quiescing) | 2693 | if (hub->quiescing) |
2598 | goto loop; | 2694 | goto loop_autopm; |
2599 | 2695 | ||
2600 | if (hub->error) { | 2696 | if (hub->error) { |
2601 | dev_dbg (hub_dev, "resetting for error %d\n", | 2697 | dev_dbg (hub_dev, "resetting for error %d\n", |
@@ -2605,7 +2701,7 @@ static void hub_events(void) | |||
2605 | if (ret) { | 2701 | if (ret) { |
2606 | dev_dbg (hub_dev, | 2702 | dev_dbg (hub_dev, |
2607 | "error resetting hub: %d\n", ret); | 2703 | "error resetting hub: %d\n", ret); |
2608 | goto loop; | 2704 | goto loop_autopm; |
2609 | } | 2705 | } |
2610 | 2706 | ||
2611 | hub->nerrors = 0; | 2707 | hub->nerrors = 0; |
@@ -2733,6 +2829,10 @@ static void hub_events(void) | |||
2733 | if (!hdev->parent && !hub->busy_bits[0]) | 2829 | if (!hdev->parent && !hub->busy_bits[0]) |
2734 | usb_enable_root_hub_irq(hdev->bus); | 2830 | usb_enable_root_hub_irq(hdev->bus); |
2735 | 2831 | ||
2832 | loop_autopm: | ||
2833 | /* Allow autosuspend if we're not going to run again */ | ||
2834 | if (list_empty(&hub->event_list)) | ||
2835 | usb_autopm_enable(intf); | ||
2736 | loop: | 2836 | loop: |
2737 | usb_unlock_device(hdev); | 2837 | usb_unlock_device(hdev); |
2738 | usb_put_intf(intf); | 2838 | usb_put_intf(intf); |
@@ -2774,6 +2874,7 @@ static struct usb_driver hub_driver = { | |||
2774 | .post_reset = hub_post_reset, | 2874 | .post_reset = hub_post_reset, |
2775 | .ioctl = hub_ioctl, | 2875 | .ioctl = hub_ioctl, |
2776 | .id_table = hub_id_table, | 2876 | .id_table = hub_id_table, |
2877 | .supports_autosuspend = 1, | ||
2777 | }; | 2878 | }; |
2778 | 2879 | ||
2779 | int usb_hub_init(void) | 2880 | int usb_hub_init(void) |
@@ -2998,7 +3099,7 @@ int usb_reset_composite_device(struct usb_device *udev, | |||
2998 | } | 3099 | } |
2999 | 3100 | ||
3000 | /* Prevent autosuspend during the reset */ | 3101 | /* Prevent autosuspend during the reset */ |
3001 | usb_autoresume_device(udev, 1); | 3102 | usb_autoresume_device(udev); |
3002 | 3103 | ||
3003 | if (iface && iface->condition != USB_INTERFACE_BINDING) | 3104 | if (iface && iface->condition != USB_INTERFACE_BINDING) |
3004 | iface = NULL; | 3105 | iface = NULL; |
@@ -3041,7 +3142,7 @@ int usb_reset_composite_device(struct usb_device *udev, | |||
3041 | } | 3142 | } |
3042 | } | 3143 | } |
3043 | 3144 | ||
3044 | usb_autosuspend_device(udev, 1); | 3145 | usb_autosuspend_device(udev); |
3045 | return ret; | 3146 | return ret; |
3046 | } | 3147 | } |
3047 | EXPORT_SYMBOL(usb_reset_composite_device); | 3148 | EXPORT_SYMBOL(usb_reset_composite_device); |
diff --git a/drivers/usb/core/hub.h b/drivers/usb/core/hub.h index 0f8e82a4d480..cf9559c6c9b6 100644 --- a/drivers/usb/core/hub.h +++ b/drivers/usb/core/hub.h | |||
@@ -192,45 +192,4 @@ struct usb_tt_clear { | |||
192 | 192 | ||
193 | extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe); | 193 | extern void usb_hub_tt_clear_buffer (struct usb_device *dev, int pipe); |
194 | 194 | ||
195 | struct usb_hub { | ||
196 | struct device *intfdev; /* the "interface" device */ | ||
197 | struct usb_device *hdev; | ||
198 | struct urb *urb; /* for interrupt polling pipe */ | ||
199 | |||
200 | /* buffer for urb ... with extra space in case of babble */ | ||
201 | char (*buffer)[8]; | ||
202 | dma_addr_t buffer_dma; /* DMA address for buffer */ | ||
203 | union { | ||
204 | struct usb_hub_status hub; | ||
205 | struct usb_port_status port; | ||
206 | } *status; /* buffer for status reports */ | ||
207 | |||
208 | int error; /* last reported error */ | ||
209 | int nerrors; /* track consecutive errors */ | ||
210 | |||
211 | struct list_head event_list; /* hubs w/data or errs ready */ | ||
212 | unsigned long event_bits[1]; /* status change bitmask */ | ||
213 | unsigned long change_bits[1]; /* ports with logical connect | ||
214 | status change */ | ||
215 | unsigned long busy_bits[1]; /* ports being reset or | ||
216 | resumed */ | ||
217 | #if USB_MAXCHILDREN > 31 /* 8*sizeof(unsigned long) - 1 */ | ||
218 | #error event_bits[] is too short! | ||
219 | #endif | ||
220 | |||
221 | struct usb_hub_descriptor *descriptor; /* class descriptor */ | ||
222 | struct usb_tt tt; /* Transaction Translator */ | ||
223 | |||
224 | unsigned mA_per_port; /* current for each child */ | ||
225 | |||
226 | unsigned limited_power:1; | ||
227 | unsigned quiescing:1; | ||
228 | unsigned activating:1; | ||
229 | unsigned resume_root_hub:1; | ||
230 | |||
231 | unsigned has_indicators:1; | ||
232 | enum hub_led_mode indicator[USB_MAXCHILDREN]; | ||
233 | struct work_struct leds; | ||
234 | }; | ||
235 | |||
236 | #endif /* __LINUX_HUB_H */ | 195 | #endif /* __LINUX_HUB_H */ |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index fccd1952bad3..29b0fa9ff9d0 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -764,7 +764,7 @@ int usb_string(struct usb_device *dev, int index, char *buf, size_t size) | |||
764 | err = -EINVAL; | 764 | err = -EINVAL; |
765 | goto errout; | 765 | goto errout; |
766 | } else { | 766 | } else { |
767 | dev->have_langid = -1; | 767 | dev->have_langid = 1; |
768 | dev->string_langid = tbuf[2] | (tbuf[3]<< 8); | 768 | dev->string_langid = tbuf[2] | (tbuf[3]<< 8); |
769 | /* always use the first langid listed */ | 769 | /* always use the first langid listed */ |
770 | dev_dbg (&dev->dev, "default language 0x%04x\n", | 770 | dev_dbg (&dev->dev, "default language 0x%04x\n", |
@@ -828,10 +828,7 @@ char *usb_cache_string(struct usb_device *udev, int index) | |||
828 | * Context: !in_interrupt () | 828 | * Context: !in_interrupt () |
829 | * | 829 | * |
830 | * Updates the copy of the device descriptor stored in the device structure, | 830 | * Updates the copy of the device descriptor stored in the device structure, |
831 | * which dedicates space for this purpose. Note that several fields are | 831 | * which dedicates space for this purpose. |
832 | * converted to the host CPU's byte order: the USB version (bcdUSB), and | ||
833 | * vendors product and version fields (idVendor, idProduct, and bcdDevice). | ||
834 | * That lets device drivers compare against non-byteswapped constants. | ||
835 | * | 832 | * |
836 | * Not exported, only for use by the core. If drivers really want to read | 833 | * Not exported, only for use by the core. If drivers really want to read |
837 | * the device descriptor directly, they can call usb_get_descriptor() with | 834 | * the device descriptor directly, they can call usb_get_descriptor() with |
@@ -1401,7 +1398,7 @@ free_interfaces: | |||
1401 | } | 1398 | } |
1402 | 1399 | ||
1403 | /* Wake up the device so we can send it the Set-Config request */ | 1400 | /* Wake up the device so we can send it the Set-Config request */ |
1404 | ret = usb_autoresume_device(dev, 1); | 1401 | ret = usb_autoresume_device(dev); |
1405 | if (ret) | 1402 | if (ret) |
1406 | goto free_interfaces; | 1403 | goto free_interfaces; |
1407 | 1404 | ||
@@ -1424,7 +1421,7 @@ free_interfaces: | |||
1424 | dev->actconfig = cp; | 1421 | dev->actconfig = cp; |
1425 | if (!cp) { | 1422 | if (!cp) { |
1426 | usb_set_device_state(dev, USB_STATE_ADDRESS); | 1423 | usb_set_device_state(dev, USB_STATE_ADDRESS); |
1427 | usb_autosuspend_device(dev, 1); | 1424 | usb_autosuspend_device(dev); |
1428 | goto free_interfaces; | 1425 | goto free_interfaces; |
1429 | } | 1426 | } |
1430 | usb_set_device_state(dev, USB_STATE_CONFIGURED); | 1427 | usb_set_device_state(dev, USB_STATE_CONFIGURED); |
@@ -1493,7 +1490,7 @@ free_interfaces: | |||
1493 | usb_create_sysfs_intf_files (intf); | 1490 | usb_create_sysfs_intf_files (intf); |
1494 | } | 1491 | } |
1495 | 1492 | ||
1496 | usb_autosuspend_device(dev, 1); | 1493 | usb_autosuspend_device(dev); |
1497 | return 0; | 1494 | return 0; |
1498 | } | 1495 | } |
1499 | 1496 | ||
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c index 467cb02832f3..81cb52564e68 100644 --- a/drivers/usb/core/usb.c +++ b/drivers/usb/core/usb.c | |||
@@ -200,13 +200,6 @@ static void ksuspend_usb_cleanup(void) | |||
200 | destroy_workqueue(ksuspend_usb_wq); | 200 | destroy_workqueue(ksuspend_usb_wq); |
201 | } | 201 | } |
202 | 202 | ||
203 | #else | ||
204 | |||
205 | #define ksuspend_usb_init() 0 | ||
206 | #define ksuspend_usb_cleanup() do {} while (0) | ||
207 | |||
208 | #endif | ||
209 | |||
210 | #ifdef CONFIG_USB_SUSPEND | 203 | #ifdef CONFIG_USB_SUSPEND |
211 | 204 | ||
212 | /* usb_autosuspend_work - callback routine to autosuspend a USB device */ | 205 | /* usb_autosuspend_work - callback routine to autosuspend a USB device */ |
@@ -225,7 +218,14 @@ static void usb_autosuspend_work(void *_udev) | |||
225 | static void usb_autosuspend_work(void *_udev) | 218 | static void usb_autosuspend_work(void *_udev) |
226 | {} | 219 | {} |
227 | 220 | ||
228 | #endif | 221 | #endif /* CONFIG_USB_SUSPEND */ |
222 | |||
223 | #else | ||
224 | |||
225 | #define ksuspend_usb_init() 0 | ||
226 | #define ksuspend_usb_cleanup() do {} while (0) | ||
227 | |||
228 | #endif /* CONFIG_PM */ | ||
229 | 229 | ||
230 | /** | 230 | /** |
231 | * usb_alloc_dev - usb device constructor (usbcore-internal) | 231 | * usb_alloc_dev - usb device constructor (usbcore-internal) |
@@ -537,138 +537,6 @@ int usb_get_current_frame_number(struct usb_device *dev) | |||
537 | return usb_hcd_get_frame_number (dev); | 537 | return usb_hcd_get_frame_number (dev); |
538 | } | 538 | } |
539 | 539 | ||
540 | /** | ||
541 | * usb_endpoint_dir_in - check if the endpoint has IN direction | ||
542 | * @epd: endpoint to be checked | ||
543 | * | ||
544 | * Returns true if the endpoint is of type IN, otherwise it returns false. | ||
545 | */ | ||
546 | int usb_endpoint_dir_in(const struct usb_endpoint_descriptor *epd) | ||
547 | { | ||
548 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_IN); | ||
549 | } | ||
550 | |||
551 | /** | ||
552 | * usb_endpoint_dir_out - check if the endpoint has OUT direction | ||
553 | * @epd: endpoint to be checked | ||
554 | * | ||
555 | * Returns true if the endpoint is of type OUT, otherwise it returns false. | ||
556 | */ | ||
557 | int usb_endpoint_dir_out(const struct usb_endpoint_descriptor *epd) | ||
558 | { | ||
559 | return ((epd->bEndpointAddress & USB_ENDPOINT_DIR_MASK) == USB_DIR_OUT); | ||
560 | } | ||
561 | |||
562 | /** | ||
563 | * usb_endpoint_xfer_bulk - check if the endpoint has bulk transfer type | ||
564 | * @epd: endpoint to be checked | ||
565 | * | ||
566 | * Returns true if the endpoint is of type bulk, otherwise it returns false. | ||
567 | */ | ||
568 | int usb_endpoint_xfer_bulk(const struct usb_endpoint_descriptor *epd) | ||
569 | { | ||
570 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
571 | USB_ENDPOINT_XFER_BULK); | ||
572 | } | ||
573 | |||
574 | /** | ||
575 | * usb_endpoint_xfer_int - check if the endpoint has interrupt transfer type | ||
576 | * @epd: endpoint to be checked | ||
577 | * | ||
578 | * Returns true if the endpoint is of type interrupt, otherwise it returns | ||
579 | * false. | ||
580 | */ | ||
581 | int usb_endpoint_xfer_int(const struct usb_endpoint_descriptor *epd) | ||
582 | { | ||
583 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
584 | USB_ENDPOINT_XFER_INT); | ||
585 | } | ||
586 | |||
587 | /** | ||
588 | * usb_endpoint_xfer_isoc - check if the endpoint has isochronous transfer type | ||
589 | * @epd: endpoint to be checked | ||
590 | * | ||
591 | * Returns true if the endpoint is of type isochronous, otherwise it returns | ||
592 | * false. | ||
593 | */ | ||
594 | int usb_endpoint_xfer_isoc(const struct usb_endpoint_descriptor *epd) | ||
595 | { | ||
596 | return ((epd->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK) == | ||
597 | USB_ENDPOINT_XFER_ISOC); | ||
598 | } | ||
599 | |||
600 | /** | ||
601 | * usb_endpoint_is_bulk_in - check if the endpoint is bulk IN | ||
602 | * @epd: endpoint to be checked | ||
603 | * | ||
604 | * Returns true if the endpoint has bulk transfer type and IN direction, | ||
605 | * otherwise it returns false. | ||
606 | */ | ||
607 | int usb_endpoint_is_bulk_in(const struct usb_endpoint_descriptor *epd) | ||
608 | { | ||
609 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_in(epd)); | ||
610 | } | ||
611 | |||
612 | /** | ||
613 | * usb_endpoint_is_bulk_out - check if the endpoint is bulk OUT | ||
614 | * @epd: endpoint to be checked | ||
615 | * | ||
616 | * Returns true if the endpoint has bulk transfer type and OUT direction, | ||
617 | * otherwise it returns false. | ||
618 | */ | ||
619 | int usb_endpoint_is_bulk_out(const struct usb_endpoint_descriptor *epd) | ||
620 | { | ||
621 | return (usb_endpoint_xfer_bulk(epd) && usb_endpoint_dir_out(epd)); | ||
622 | } | ||
623 | |||
624 | /** | ||
625 | * usb_endpoint_is_int_in - check if the endpoint is interrupt IN | ||
626 | * @epd: endpoint to be checked | ||
627 | * | ||
628 | * Returns true if the endpoint has interrupt transfer type and IN direction, | ||
629 | * otherwise it returns false. | ||
630 | */ | ||
631 | int usb_endpoint_is_int_in(const struct usb_endpoint_descriptor *epd) | ||
632 | { | ||
633 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_in(epd)); | ||
634 | } | ||
635 | |||
636 | /** | ||
637 | * usb_endpoint_is_int_out - check if the endpoint is interrupt OUT | ||
638 | * @epd: endpoint to be checked | ||
639 | * | ||
640 | * Returns true if the endpoint has interrupt transfer type and OUT direction, | ||
641 | * otherwise it returns false. | ||
642 | */ | ||
643 | int usb_endpoint_is_int_out(const struct usb_endpoint_descriptor *epd) | ||
644 | { | ||
645 | return (usb_endpoint_xfer_int(epd) && usb_endpoint_dir_out(epd)); | ||
646 | } | ||
647 | |||
648 | /** | ||
649 | * usb_endpoint_is_isoc_in - check if the endpoint is isochronous IN | ||
650 | * @epd: endpoint to be checked | ||
651 | * | ||
652 | * Returns true if the endpoint has isochronous transfer type and IN direction, | ||
653 | * otherwise it returns false. | ||
654 | */ | ||
655 | int usb_endpoint_is_isoc_in(const struct usb_endpoint_descriptor *epd) | ||
656 | { | ||
657 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_in(epd)); | ||
658 | } | ||
659 | |||
660 | /** | ||
661 | * usb_endpoint_is_isoc_out - check if the endpoint is isochronous OUT | ||
662 | * @epd: endpoint to be checked | ||
663 | * | ||
664 | * Returns true if the endpoint has isochronous transfer type and OUT direction, | ||
665 | * otherwise it returns false. | ||
666 | */ | ||
667 | int usb_endpoint_is_isoc_out(const struct usb_endpoint_descriptor *epd) | ||
668 | { | ||
669 | return (usb_endpoint_xfer_isoc(epd) && usb_endpoint_dir_out(epd)); | ||
670 | } | ||
671 | |||
672 | /*-------------------------------------------------------------------*/ | 540 | /*-------------------------------------------------------------------*/ |
673 | /* | 541 | /* |
674 | * __usb_get_extra_descriptor() finds a descriptor of specific type in the | 542 | * __usb_get_extra_descriptor() finds a descriptor of specific type in the |
@@ -1102,18 +970,6 @@ EXPORT_SYMBOL(__usb_get_extra_descriptor); | |||
1102 | EXPORT_SYMBOL(usb_find_device); | 970 | EXPORT_SYMBOL(usb_find_device); |
1103 | EXPORT_SYMBOL(usb_get_current_frame_number); | 971 | EXPORT_SYMBOL(usb_get_current_frame_number); |
1104 | 972 | ||
1105 | EXPORT_SYMBOL_GPL(usb_endpoint_dir_in); | ||
1106 | EXPORT_SYMBOL_GPL(usb_endpoint_dir_out); | ||
1107 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_bulk); | ||
1108 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_int); | ||
1109 | EXPORT_SYMBOL_GPL(usb_endpoint_xfer_isoc); | ||
1110 | EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_in); | ||
1111 | EXPORT_SYMBOL_GPL(usb_endpoint_is_bulk_out); | ||
1112 | EXPORT_SYMBOL_GPL(usb_endpoint_is_int_in); | ||
1113 | EXPORT_SYMBOL_GPL(usb_endpoint_is_int_out); | ||
1114 | EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_in); | ||
1115 | EXPORT_SYMBOL_GPL(usb_endpoint_is_isoc_out); | ||
1116 | |||
1117 | EXPORT_SYMBOL (usb_buffer_alloc); | 973 | EXPORT_SYMBOL (usb_buffer_alloc); |
1118 | EXPORT_SYMBOL (usb_buffer_free); | 974 | EXPORT_SYMBOL (usb_buffer_free); |
1119 | 975 | ||
diff --git a/drivers/usb/core/usb.h b/drivers/usb/core/usb.h index 13322e33f912..17830a81be14 100644 --- a/drivers/usb/core/usb.h +++ b/drivers/usb/core/usb.h | |||
@@ -64,14 +64,13 @@ static inline void usb_pm_unlock(struct usb_device *udev) {} | |||
64 | 64 | ||
65 | #define USB_AUTOSUSPEND_DELAY (HZ*2) | 65 | #define USB_AUTOSUSPEND_DELAY (HZ*2) |
66 | 66 | ||
67 | extern void usb_autosuspend_device(struct usb_device *udev, int dec_busy_cnt); | 67 | extern void usb_autosuspend_device(struct usb_device *udev); |
68 | extern int usb_autoresume_device(struct usb_device *udev, int inc_busy_cnt); | 68 | extern int usb_autoresume_device(struct usb_device *udev); |
69 | 69 | ||
70 | #else | 70 | #else |
71 | 71 | ||
72 | #define usb_autosuspend_device(udev, dec_busy_cnt) do {} while (0) | 72 | #define usb_autosuspend_device(udev) do {} while (0) |
73 | static inline int usb_autoresume_device(struct usb_device *udev, | 73 | static inline int usb_autoresume_device(struct usb_device *udev) |
74 | int inc_busy_cnt) | ||
75 | { | 74 | { |
76 | return 0; | 75 | return 0; |
77 | } | 76 | } |