diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2007-05-04 11:51:54 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-12 19:29:46 -0400 |
commit | b6f6436da0c6853eedad86f5075b139c1a3bcb5d (patch) | |
tree | 60082b119bcd08baa2a6f24daab6bb1c864f974e /drivers/usb/core/generic.c | |
parent | 4d461095ef6967324bc5da5d65d23ad27fc604f9 (diff) |
USB: move bus_suspend and bus_resume method calls
This patch (as885) moves the root-hub bus_suspend() and bus_resume()
method calls from the hub driver's suspend and resume methods into the
usb_generic driver methods, where they make just as much sense.
Their old locations were not fully correct. For example, in a kernel
compiled without CONFIG_USB_SUSPEND, if one were to do:
echo -n 1-0:1.0 >/sys/bus/usb/drivers/hub/unbind
to unbind the hub driver from a root hub, there would then be no way
to suspend that root hub. Attempts to put the system to sleep would
fail; the USB controller driver would refuse to suspend because the
root hub was still active.
The patch also makes a very slight change in the way devices with no
driver are handled during suspend. Rather than doing a standard USB
port-suspend directly, now the suspend routine in usb_generic is
called. In practice this should never affect anyone.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/core/generic.c')
-rw-r--r-- | drivers/usb/core/generic.c | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/drivers/usb/core/generic.c b/drivers/usb/core/generic.c index e7ec9b6b7a93..7cbf992adccd 100644 --- a/drivers/usb/core/generic.c +++ b/drivers/usb/core/generic.c | |||
@@ -19,6 +19,7 @@ | |||
19 | 19 | ||
20 | #include <linux/usb.h> | 20 | #include <linux/usb.h> |
21 | #include "usb.h" | 21 | #include "usb.h" |
22 | #include "hcd.h" | ||
22 | 23 | ||
23 | static inline const char *plural(int n) | 24 | static inline const char *plural(int n) |
24 | { | 25 | { |
@@ -193,12 +194,46 @@ static void generic_disconnect(struct usb_device *udev) | |||
193 | 194 | ||
194 | static int generic_suspend(struct usb_device *udev, pm_message_t msg) | 195 | static int generic_suspend(struct usb_device *udev, pm_message_t msg) |
195 | { | 196 | { |
196 | return usb_port_suspend(udev); | 197 | int rc; |
198 | |||
199 | rc = usb_port_suspend(udev); | ||
200 | |||
201 | /* Root hubs don't have upstream ports to suspend, | ||
202 | * so the line above won't do much for them. We have to | ||
203 | * shut down their downstream HC-to-USB interfaces manually, | ||
204 | * by doing a bus (or "global") suspend. | ||
205 | */ | ||
206 | if (rc == 0 && !udev->parent) { | ||
207 | rc = hcd_bus_suspend(udev->bus); | ||
208 | if (rc) { | ||
209 | dev_dbg(&udev->dev, "'global' suspend %d\n", rc); | ||
210 | usb_port_resume(udev); | ||
211 | } | ||
212 | } | ||
213 | return rc; | ||
197 | } | 214 | } |
198 | 215 | ||
199 | static int generic_resume(struct usb_device *udev) | 216 | static int generic_resume(struct usb_device *udev) |
200 | { | 217 | { |
201 | return usb_port_resume(udev); | 218 | int rc; |
219 | |||
220 | rc = usb_port_resume(udev); | ||
221 | |||
222 | /* Root hubs don't have upstream ports to resume or reset, | ||
223 | * so the line above won't do much for them. We have to | ||
224 | * start up their downstream HC-to-USB interfaces manually, | ||
225 | * by doing a bus (or "global") resume. | ||
226 | */ | ||
227 | if (rc == 0 && !udev->parent) { | ||
228 | rc = hcd_bus_resume(udev->bus); | ||
229 | if (rc) | ||
230 | dev_dbg(&udev->dev, "'global' resume %d\n", rc); | ||
231 | else { | ||
232 | /* TRSMRCY = 10 msec */ | ||
233 | msleep(10); | ||
234 | } | ||
235 | } | ||
236 | return rc; | ||
202 | } | 237 | } |
203 | 238 | ||
204 | #endif /* CONFIG_PM */ | 239 | #endif /* CONFIG_PM */ |