diff options
author | David Howells <dhowells@redhat.com> | 2006-12-05 09:37:56 -0500 |
---|---|---|
committer | David Howells <dhowells@warthog.cambridge.redhat.com> | 2006-12-05 09:37:56 -0500 |
commit | 4c1ac1b49122b805adfa4efc620592f68dccf5db (patch) | |
tree | 87557f4bc2fd4fe65b7570489c2f610c45c0adcd /drivers/usb/core/hub.c | |
parent | c4028958b6ecad064b1a6303a6a5906d4fe48d73 (diff) | |
parent | d916faace3efc0bf19fe9a615a1ab8fa1a24cd93 (diff) |
Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
Conflicts:
drivers/infiniband/core/iwcm.c
drivers/net/chelsio/cxgb2.c
drivers/net/wireless/bcm43xx/bcm43xx_main.c
drivers/net/wireless/prism54/islpci_eth.c
drivers/usb/core/hub.h
drivers/usb/input/hid-core.c
net/core/netpoll.c
Fix up merge failures with Linus's head and fix new compilation failures.
Signed-Off-By: David Howells <dhowells@redhat.com>
Diffstat (limited to 'drivers/usb/core/hub.c')
-rw-r--r-- | drivers/usb/core/hub.c | 234 |
1 files changed, 168 insertions, 66 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index ad0ffbe8f7d7..39186db1015f 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); |
@@ -277,6 +328,9 @@ static void kick_khubd(struct usb_hub *hub) | |||
277 | { | 328 | { |
278 | unsigned long flags; | 329 | unsigned long flags; |
279 | 330 | ||
331 | /* Suppress autosuspend until khubd runs */ | ||
332 | to_usb_interface(hub->intfdev)->pm_usage_cnt = 1; | ||
333 | |||
280 | spin_lock_irqsave(&hub_event_lock, flags); | 334 | spin_lock_irqsave(&hub_event_lock, flags); |
281 | if (list_empty(&hub->event_list)) { | 335 | if (list_empty(&hub->event_list)) { |
282 | list_add_tail(&hub->event_list, &hub_event_list); | 336 | list_add_tail(&hub->event_list, &hub_event_list); |
@@ -459,7 +513,6 @@ static void hub_quiesce(struct usb_hub *hub) | |||
459 | /* (nonblocking) khubd and related activity won't re-trigger */ | 513 | /* (nonblocking) khubd and related activity won't re-trigger */ |
460 | hub->quiescing = 1; | 514 | hub->quiescing = 1; |
461 | hub->activating = 0; | 515 | hub->activating = 0; |
462 | hub->resume_root_hub = 0; | ||
463 | 516 | ||
464 | /* (blocking) stop khubd and related activity */ | 517 | /* (blocking) stop khubd and related activity */ |
465 | usb_kill_urb(hub->urb); | 518 | usb_kill_urb(hub->urb); |
@@ -475,7 +528,7 @@ static void hub_activate(struct usb_hub *hub) | |||
475 | 528 | ||
476 | hub->quiescing = 0; | 529 | hub->quiescing = 0; |
477 | hub->activating = 1; | 530 | hub->activating = 1; |
478 | hub->resume_root_hub = 0; | 531 | |
479 | status = usb_submit_urb(hub->urb, GFP_NOIO); | 532 | status = usb_submit_urb(hub->urb, GFP_NOIO); |
480 | if (status < 0) | 533 | if (status < 0) |
481 | dev_err(hub->intfdev, "activate --> %d\n", status); | 534 | dev_err(hub->intfdev, "activate --> %d\n", status); |
@@ -761,7 +814,12 @@ static int hub_configure(struct usb_hub *hub, | |||
761 | dev_dbg(hub_dev, "%sover-current condition exists\n", | 814 | dev_dbg(hub_dev, "%sover-current condition exists\n", |
762 | (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); | 815 | (hubstatus & HUB_STATUS_OVERCURRENT) ? "" : "no "); |
763 | 816 | ||
764 | /* set up the interrupt endpoint */ | 817 | /* set up the interrupt endpoint |
818 | * We use the EP's maxpacket size instead of (PORTS+1+7)/8 | ||
819 | * bytes as USB2.0[11.12.3] says because some hubs are known | ||
820 | * to send more data (and thus cause overflow). For root hubs, | ||
821 | * maxpktsize is defined in hcd.c's fake endpoint descriptors | ||
822 | * to be big enough for at least USB_MAXCHILDREN ports. */ | ||
765 | pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); | 823 | pipe = usb_rcvintpipe(hdev, endpoint->bEndpointAddress); |
766 | maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); | 824 | maxp = usb_maxpacket(hdev, pipe, usb_pipeout(pipe)); |
767 | 825 | ||
@@ -885,6 +943,7 @@ descriptor_error: | |||
885 | INIT_DELAYED_WORK(&hub->leds, led_work); | 943 | INIT_DELAYED_WORK(&hub->leds, led_work); |
886 | 944 | ||
887 | usb_set_intfdata (intf, hub); | 945 | usb_set_intfdata (intf, hub); |
946 | intf->needs_remote_wakeup = 1; | ||
888 | 947 | ||
889 | if (hdev->speed == USB_SPEED_HIGH) | 948 | if (hdev->speed == USB_SPEED_HIGH) |
890 | highspeed_hubs++; | 949 | highspeed_hubs++; |
@@ -982,6 +1041,8 @@ static void recursively_mark_NOTATTACHED(struct usb_device *udev) | |||
982 | if (udev->children[i]) | 1041 | if (udev->children[i]) |
983 | recursively_mark_NOTATTACHED(udev->children[i]); | 1042 | recursively_mark_NOTATTACHED(udev->children[i]); |
984 | } | 1043 | } |
1044 | if (udev->state == USB_STATE_SUSPENDED) | ||
1045 | udev->discon_suspended = 1; | ||
985 | udev->state = USB_STATE_NOTATTACHED; | 1046 | udev->state = USB_STATE_NOTATTACHED; |
986 | } | 1047 | } |
987 | 1048 | ||
@@ -1171,6 +1232,14 @@ void usb_disconnect(struct usb_device **pdev) | |||
1171 | *pdev = NULL; | 1232 | *pdev = NULL; |
1172 | spin_unlock_irq(&device_state_lock); | 1233 | spin_unlock_irq(&device_state_lock); |
1173 | 1234 | ||
1235 | /* Decrement the parent's count of unsuspended children */ | ||
1236 | if (udev->parent) { | ||
1237 | usb_pm_lock(udev); | ||
1238 | if (!udev->discon_suspended) | ||
1239 | usb_autosuspend_device(udev->parent); | ||
1240 | usb_pm_unlock(udev); | ||
1241 | } | ||
1242 | |||
1174 | put_device(&udev->dev); | 1243 | put_device(&udev->dev); |
1175 | } | 1244 | } |
1176 | 1245 | ||
@@ -1193,29 +1262,17 @@ static inline void show_string(struct usb_device *udev, char *id, char *string) | |||
1193 | static int __usb_port_suspend(struct usb_device *, int port1); | 1262 | static int __usb_port_suspend(struct usb_device *, int port1); |
1194 | #endif | 1263 | #endif |
1195 | 1264 | ||
1196 | /** | 1265 | static int __usb_new_device(void *void_data) |
1197 | * usb_new_device - perform initial device setup (usbcore-internal) | ||
1198 | * @udev: newly addressed device (in ADDRESS state) | ||
1199 | * | ||
1200 | * This is called with devices which have been enumerated, but not yet | ||
1201 | * configured. The device descriptor is available, but not descriptors | ||
1202 | * for any device configuration. The caller must have locked either | ||
1203 | * the parent hub (if udev is a normal device) or else the | ||
1204 | * usb_bus_list_lock (if udev is a root hub). The parent's pointer to | ||
1205 | * udev has already been installed, but udev is not yet visible through | ||
1206 | * sysfs or other filesystem code. | ||
1207 | * | ||
1208 | * Returns 0 for success (device is configured and listed, with its | ||
1209 | * interfaces, in sysfs); else a negative errno value. | ||
1210 | * | ||
1211 | * This call is synchronous, and may not be used in an interrupt context. | ||
1212 | * | ||
1213 | * Only the hub driver or root-hub registrar should ever call this. | ||
1214 | */ | ||
1215 | int usb_new_device(struct usb_device *udev) | ||
1216 | { | 1266 | { |
1267 | struct usb_device *udev = void_data; | ||
1217 | int err; | 1268 | int err; |
1218 | 1269 | ||
1270 | /* Lock ourself into memory in order to keep a probe sequence | ||
1271 | * sleeping in a new thread from allowing us to be unloaded. | ||
1272 | */ | ||
1273 | if (!try_module_get(THIS_MODULE)) | ||
1274 | return -EINVAL; | ||
1275 | |||
1219 | err = usb_get_configuration(udev); | 1276 | err = usb_get_configuration(udev); |
1220 | if (err < 0) { | 1277 | if (err < 0) { |
1221 | dev_err(&udev->dev, "can't read configurations, error %d\n", | 1278 | dev_err(&udev->dev, "can't read configurations, error %d\n", |
@@ -1311,13 +1368,56 @@ int usb_new_device(struct usb_device *udev) | |||
1311 | goto fail; | 1368 | goto fail; |
1312 | } | 1369 | } |
1313 | 1370 | ||
1314 | return 0; | 1371 | /* Increment the parent's count of unsuspended children */ |
1372 | if (udev->parent) | ||
1373 | usb_autoresume_device(udev->parent); | ||
1374 | |||
1375 | exit: | ||
1376 | module_put(THIS_MODULE); | ||
1377 | return err; | ||
1315 | 1378 | ||
1316 | fail: | 1379 | fail: |
1317 | usb_set_device_state(udev, USB_STATE_NOTATTACHED); | 1380 | usb_set_device_state(udev, USB_STATE_NOTATTACHED); |
1318 | return err; | 1381 | goto exit; |
1319 | } | 1382 | } |
1320 | 1383 | ||
1384 | /** | ||
1385 | * usb_new_device - perform initial device setup (usbcore-internal) | ||
1386 | * @udev: newly addressed device (in ADDRESS state) | ||
1387 | * | ||
1388 | * This is called with devices which have been enumerated, but not yet | ||
1389 | * configured. The device descriptor is available, but not descriptors | ||
1390 | * for any device configuration. The caller must have locked either | ||
1391 | * the parent hub (if udev is a normal device) or else the | ||
1392 | * usb_bus_list_lock (if udev is a root hub). The parent's pointer to | ||
1393 | * udev has already been installed, but udev is not yet visible through | ||
1394 | * sysfs or other filesystem code. | ||
1395 | * | ||
1396 | * The return value for this function depends on if the | ||
1397 | * multithread_probe variable is set or not. If it's set, it will | ||
1398 | * return a if the probe thread was successfully created or not. If the | ||
1399 | * variable is not set, it will return if the device is configured | ||
1400 | * properly or not. interfaces, in sysfs); else a negative errno value. | ||
1401 | * | ||
1402 | * This call is synchronous, and may not be used in an interrupt context. | ||
1403 | * | ||
1404 | * Only the hub driver or root-hub registrar should ever call this. | ||
1405 | */ | ||
1406 | int usb_new_device(struct usb_device *udev) | ||
1407 | { | ||
1408 | struct task_struct *probe_task; | ||
1409 | int ret = 0; | ||
1410 | |||
1411 | if (multithread_probe) { | ||
1412 | probe_task = kthread_run(__usb_new_device, udev, | ||
1413 | "usb-probe-%s", udev->devnum); | ||
1414 | if (IS_ERR(probe_task)) | ||
1415 | ret = PTR_ERR(probe_task); | ||
1416 | } else | ||
1417 | ret = __usb_new_device(udev); | ||
1418 | |||
1419 | return ret; | ||
1420 | } | ||
1321 | 1421 | ||
1322 | static int hub_port_status(struct usb_hub *hub, int port1, | 1422 | static int hub_port_status(struct usb_hub *hub, int port1, |
1323 | u16 *status, u16 *change) | 1423 | u16 *status, u16 *change) |
@@ -1325,10 +1425,12 @@ static int hub_port_status(struct usb_hub *hub, int port1, | |||
1325 | int ret; | 1425 | int ret; |
1326 | 1426 | ||
1327 | ret = get_port_status(hub->hdev, port1, &hub->status->port); | 1427 | ret = get_port_status(hub->hdev, port1, &hub->status->port); |
1328 | if (ret < 0) | 1428 | if (ret < 4) { |
1329 | dev_err (hub->intfdev, | 1429 | dev_err (hub->intfdev, |
1330 | "%s failed (err = %d)\n", __FUNCTION__, ret); | 1430 | "%s failed (err = %d)\n", __FUNCTION__, ret); |
1331 | else { | 1431 | if (ret >= 0) |
1432 | ret = -EIO; | ||
1433 | } else { | ||
1332 | *status = le16_to_cpu(hub->status->port.wPortStatus); | 1434 | *status = le16_to_cpu(hub->status->port.wPortStatus); |
1333 | *change = le16_to_cpu(hub->status->port.wPortChange); | 1435 | *change = le16_to_cpu(hub->status->port.wPortChange); |
1334 | ret = 0; | 1436 | ret = 0; |
@@ -1676,6 +1778,12 @@ static int | |||
1676 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | 1778 | hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) |
1677 | { | 1779 | { |
1678 | int status; | 1780 | int status; |
1781 | u16 portchange, portstatus; | ||
1782 | |||
1783 | /* Skip the initial Clear-Suspend step for a remote wakeup */ | ||
1784 | status = hub_port_status(hub, port1, &portstatus, &portchange); | ||
1785 | if (status == 0 && !(portstatus & USB_PORT_STAT_SUSPEND)) | ||
1786 | goto SuspendCleared; | ||
1679 | 1787 | ||
1680 | // dev_dbg(hub->intfdev, "resume port %d\n", port1); | 1788 | // dev_dbg(hub->intfdev, "resume port %d\n", port1); |
1681 | 1789 | ||
@@ -1689,9 +1797,6 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | |||
1689 | "can't resume port %d, status %d\n", | 1797 | "can't resume port %d, status %d\n", |
1690 | port1, status); | 1798 | port1, status); |
1691 | } else { | 1799 | } else { |
1692 | u16 devstatus; | ||
1693 | u16 portchange; | ||
1694 | |||
1695 | /* drive resume for at least 20 msec */ | 1800 | /* drive resume for at least 20 msec */ |
1696 | if (udev) | 1801 | if (udev) |
1697 | dev_dbg(&udev->dev, "usb %sresume\n", | 1802 | dev_dbg(&udev->dev, "usb %sresume\n", |
@@ -1706,16 +1811,15 @@ hub_port_resume(struct usb_hub *hub, int port1, struct usb_device *udev) | |||
1706 | * stop resume signaling. Then finish the resume | 1811 | * stop resume signaling. Then finish the resume |
1707 | * sequence. | 1812 | * sequence. |
1708 | */ | 1813 | */ |
1709 | devstatus = portchange = 0; | 1814 | status = hub_port_status(hub, port1, &portstatus, &portchange); |
1710 | status = hub_port_status(hub, port1, | 1815 | SuspendCleared: |
1711 | &devstatus, &portchange); | ||
1712 | if (status < 0 | 1816 | if (status < 0 |
1713 | || (devstatus & LIVE_FLAGS) != LIVE_FLAGS | 1817 | || (portstatus & LIVE_FLAGS) != LIVE_FLAGS |
1714 | || (devstatus & USB_PORT_STAT_SUSPEND) != 0 | 1818 | || (portstatus & USB_PORT_STAT_SUSPEND) != 0 |
1715 | ) { | 1819 | ) { |
1716 | dev_dbg(hub->intfdev, | 1820 | dev_dbg(hub->intfdev, |
1717 | "port %d status %04x.%04x after resume, %d\n", | 1821 | "port %d status %04x.%04x after resume, %d\n", |
1718 | port1, portchange, devstatus, status); | 1822 | port1, portchange, portstatus, status); |
1719 | if (status >= 0) | 1823 | if (status >= 0) |
1720 | status = -ENODEV; | 1824 | status = -ENODEV; |
1721 | } else { | 1825 | } else { |
@@ -1776,23 +1880,16 @@ static int remote_wakeup(struct usb_device *udev) | |||
1776 | { | 1880 | { |
1777 | int status = 0; | 1881 | int status = 0; |
1778 | 1882 | ||
1779 | /* All this just to avoid sending a port-resume message | ||
1780 | * to the parent hub! */ | ||
1781 | |||
1782 | usb_lock_device(udev); | 1883 | usb_lock_device(udev); |
1783 | usb_pm_lock(udev); | ||
1784 | if (udev->state == USB_STATE_SUSPENDED) { | 1884 | if (udev->state == USB_STATE_SUSPENDED) { |
1785 | dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); | 1885 | dev_dbg(&udev->dev, "usb %sresume\n", "wakeup-"); |
1786 | /* TRSMRCY = 10 msec */ | 1886 | status = usb_autoresume_device(udev); |
1787 | msleep(10); | 1887 | |
1788 | status = finish_port_resume(udev); | 1888 | /* Give the interface drivers a chance to do something, |
1889 | * then autosuspend the device again. */ | ||
1789 | if (status == 0) | 1890 | if (status == 0) |
1790 | udev->dev.power.power_state.event = PM_EVENT_ON; | 1891 | usb_autosuspend_device(udev); |
1791 | } | 1892 | } |
1792 | usb_pm_unlock(udev); | ||
1793 | |||
1794 | if (status == 0) | ||
1795 | usb_autoresume_device(udev, 0); | ||
1796 | usb_unlock_device(udev); | 1893 | usb_unlock_device(udev); |
1797 | return status; | 1894 | return status; |
1798 | } | 1895 | } |
@@ -1856,6 +1953,8 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
1856 | } | 1953 | } |
1857 | } | 1954 | } |
1858 | 1955 | ||
1956 | dev_dbg(&intf->dev, "%s\n", __FUNCTION__); | ||
1957 | |||
1859 | /* "global suspend" of the downstream HC-to-USB interface */ | 1958 | /* "global suspend" of the downstream HC-to-USB interface */ |
1860 | if (!hdev->parent) { | 1959 | if (!hdev->parent) { |
1861 | struct usb_bus *bus = hdev->bus; | 1960 | struct usb_bus *bus = hdev->bus; |
@@ -1878,10 +1977,12 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg) | |||
1878 | 1977 | ||
1879 | static int hub_resume(struct usb_interface *intf) | 1978 | static int hub_resume(struct usb_interface *intf) |
1880 | { | 1979 | { |
1881 | struct usb_device *hdev = interface_to_usbdev(intf); | ||
1882 | struct usb_hub *hub = usb_get_intfdata (intf); | 1980 | struct usb_hub *hub = usb_get_intfdata (intf); |
1981 | struct usb_device *hdev = hub->hdev; | ||
1883 | int status; | 1982 | int status; |
1884 | 1983 | ||
1984 | dev_dbg(&intf->dev, "%s\n", __FUNCTION__); | ||
1985 | |||
1885 | /* "global resume" of the downstream HC-to-USB interface */ | 1986 | /* "global resume" of the downstream HC-to-USB interface */ |
1886 | if (!hdev->parent) { | 1987 | if (!hdev->parent) { |
1887 | struct usb_bus *bus = hdev->bus; | 1988 | struct usb_bus *bus = hdev->bus; |
@@ -1920,7 +2021,6 @@ void usb_resume_root_hub(struct usb_device *hdev) | |||
1920 | { | 2021 | { |
1921 | struct usb_hub *hub = hdev_to_hub(hdev); | 2022 | struct usb_hub *hub = hdev_to_hub(hdev); |
1922 | 2023 | ||
1923 | hub->resume_root_hub = 1; | ||
1924 | kick_khubd(hub); | 2024 | kick_khubd(hub); |
1925 | } | 2025 | } |
1926 | 2026 | ||
@@ -2557,16 +2657,13 @@ static void hub_events(void) | |||
2557 | intf = to_usb_interface(hub->intfdev); | 2657 | intf = to_usb_interface(hub->intfdev); |
2558 | hub_dev = &intf->dev; | 2658 | hub_dev = &intf->dev; |
2559 | 2659 | ||
2560 | i = hub->resume_root_hub; | 2660 | dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x\n", |
2561 | |||
2562 | dev_dbg(hub_dev, "state %d ports %d chg %04x evt %04x%s\n", | ||
2563 | hdev->state, hub->descriptor | 2661 | hdev->state, hub->descriptor |
2564 | ? hub->descriptor->bNbrPorts | 2662 | ? hub->descriptor->bNbrPorts |
2565 | : 0, | 2663 | : 0, |
2566 | /* NOTE: expects max 15 ports... */ | 2664 | /* NOTE: expects max 15 ports... */ |
2567 | (u16) hub->change_bits[0], | 2665 | (u16) hub->change_bits[0], |
2568 | (u16) hub->event_bits[0], | 2666 | (u16) hub->event_bits[0]); |
2569 | i ? ", resume root" : ""); | ||
2570 | 2667 | ||
2571 | usb_get_intf(intf); | 2668 | usb_get_intf(intf); |
2572 | spin_unlock_irq(&hub_event_lock); | 2669 | spin_unlock_irq(&hub_event_lock); |
@@ -2587,16 +2684,16 @@ static void hub_events(void) | |||
2587 | goto loop; | 2684 | goto loop; |
2588 | } | 2685 | } |
2589 | 2686 | ||
2590 | /* Is this is a root hub wanting to reactivate the downstream | 2687 | /* Autoresume */ |
2591 | * ports? If so, be sure the interface resumes even if its | 2688 | ret = usb_autopm_get_interface(intf); |
2592 | * stub "device" node was never suspended. | 2689 | if (ret) { |
2593 | */ | 2690 | dev_dbg(hub_dev, "Can't autoresume: %d\n", ret); |
2594 | if (i) | 2691 | goto loop; |
2595 | usb_autoresume_device(hdev, 0); | 2692 | } |
2596 | 2693 | ||
2597 | /* If this is an inactive or suspended hub, do nothing */ | 2694 | /* If this is an inactive hub, do nothing */ |
2598 | if (hub->quiescing) | 2695 | if (hub->quiescing) |
2599 | goto loop; | 2696 | goto loop_autopm; |
2600 | 2697 | ||
2601 | if (hub->error) { | 2698 | if (hub->error) { |
2602 | dev_dbg (hub_dev, "resetting for error %d\n", | 2699 | dev_dbg (hub_dev, "resetting for error %d\n", |
@@ -2606,7 +2703,7 @@ static void hub_events(void) | |||
2606 | if (ret) { | 2703 | if (ret) { |
2607 | dev_dbg (hub_dev, | 2704 | dev_dbg (hub_dev, |
2608 | "error resetting hub: %d\n", ret); | 2705 | "error resetting hub: %d\n", ret); |
2609 | goto loop; | 2706 | goto loop_autopm; |
2610 | } | 2707 | } |
2611 | 2708 | ||
2612 | hub->nerrors = 0; | 2709 | hub->nerrors = 0; |
@@ -2734,6 +2831,10 @@ static void hub_events(void) | |||
2734 | if (!hdev->parent && !hub->busy_bits[0]) | 2831 | if (!hdev->parent && !hub->busy_bits[0]) |
2735 | usb_enable_root_hub_irq(hdev->bus); | 2832 | usb_enable_root_hub_irq(hdev->bus); |
2736 | 2833 | ||
2834 | loop_autopm: | ||
2835 | /* Allow autosuspend if we're not going to run again */ | ||
2836 | if (list_empty(&hub->event_list)) | ||
2837 | usb_autopm_enable(intf); | ||
2737 | loop: | 2838 | loop: |
2738 | usb_unlock_device(hdev); | 2839 | usb_unlock_device(hdev); |
2739 | usb_put_intf(intf); | 2840 | usb_put_intf(intf); |
@@ -2775,6 +2876,7 @@ static struct usb_driver hub_driver = { | |||
2775 | .post_reset = hub_post_reset, | 2876 | .post_reset = hub_post_reset, |
2776 | .ioctl = hub_ioctl, | 2877 | .ioctl = hub_ioctl, |
2777 | .id_table = hub_id_table, | 2878 | .id_table = hub_id_table, |
2879 | .supports_autosuspend = 1, | ||
2778 | }; | 2880 | }; |
2779 | 2881 | ||
2780 | int usb_hub_init(void) | 2882 | int usb_hub_init(void) |
@@ -2999,7 +3101,7 @@ int usb_reset_composite_device(struct usb_device *udev, | |||
2999 | } | 3101 | } |
3000 | 3102 | ||
3001 | /* Prevent autosuspend during the reset */ | 3103 | /* Prevent autosuspend during the reset */ |
3002 | usb_autoresume_device(udev, 1); | 3104 | usb_autoresume_device(udev); |
3003 | 3105 | ||
3004 | if (iface && iface->condition != USB_INTERFACE_BINDING) | 3106 | if (iface && iface->condition != USB_INTERFACE_BINDING) |
3005 | iface = NULL; | 3107 | iface = NULL; |
@@ -3042,7 +3144,7 @@ int usb_reset_composite_device(struct usb_device *udev, | |||
3042 | } | 3144 | } |
3043 | } | 3145 | } |
3044 | 3146 | ||
3045 | usb_autosuspend_device(udev, 1); | 3147 | usb_autosuspend_device(udev); |
3046 | return ret; | 3148 | return ret; |
3047 | } | 3149 | } |
3048 | EXPORT_SYMBOL(usb_reset_composite_device); | 3150 | EXPORT_SYMBOL(usb_reset_composite_device); |