aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2007-05-04 11:51:54 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2007-07-12 19:29:46 -0400
commitb6f6436da0c6853eedad86f5075b139c1a3bcb5d (patch)
tree60082b119bcd08baa2a6f24daab6bb1c864f974e /drivers
parent4d461095ef6967324bc5da5d65d23ad27fc604f9 (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')
-rw-r--r--drivers/usb/core/driver.c11
-rw-r--r--drivers/usb/core/generic.c39
-rw-r--r--drivers/usb/core/hub.c32
3 files changed, 43 insertions, 39 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c
index 63d47946e3db..e8b447e06c54 100644
--- a/drivers/usb/core/driver.c
+++ b/drivers/usb/core/driver.c
@@ -802,14 +802,13 @@ static int usb_suspend_device(struct usb_device *udev, pm_message_t msg)
802 udev->state == USB_STATE_SUSPENDED) 802 udev->state == USB_STATE_SUSPENDED)
803 goto done; 803 goto done;
804 804
805 /* For devices that don't have a driver, we do a standard suspend. */ 805 /* For devices that don't have a driver, we do a generic suspend. */
806 if (udev->dev.driver == NULL) { 806 if (udev->dev.driver)
807 udriver = to_usb_device_driver(udev->dev.driver);
808 else {
807 udev->do_remote_wakeup = 0; 809 udev->do_remote_wakeup = 0;
808 status = usb_port_suspend(udev); 810 udriver = &usb_generic_driver;
809 goto done;
810 } 811 }
811
812 udriver = to_usb_device_driver(udev->dev.driver);
813 status = udriver->suspend(udev, msg); 812 status = udriver->suspend(udev, msg);
814 813
815done: 814done:
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
23static inline const char *plural(int n) 24static inline const char *plural(int n)
24{ 25{
@@ -193,12 +194,46 @@ static void generic_disconnect(struct usb_device *udev)
193 194
194static int generic_suspend(struct usb_device *udev, pm_message_t msg) 195static 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
199static int generic_resume(struct usb_device *udev) 216static 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 */
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index a9cf8b30bccc..8aea8559bec2 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1916,7 +1916,6 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1916 struct usb_hub *hub = usb_get_intfdata (intf); 1916 struct usb_hub *hub = usb_get_intfdata (intf);
1917 struct usb_device *hdev = hub->hdev; 1917 struct usb_device *hdev = hub->hdev;
1918 unsigned port1; 1918 unsigned port1;
1919 int status = 0;
1920 1919
1921 /* fail if children aren't already suspended */ 1920 /* fail if children aren't already suspended */
1922 for (port1 = 1; port1 <= hdev->maxchild; port1++) { 1921 for (port1 = 1; port1 <= hdev->maxchild; port1++) {
@@ -1942,44 +1941,15 @@ static int hub_suspend(struct usb_interface *intf, pm_message_t msg)
1942 1941
1943 /* stop khubd and related activity */ 1942 /* stop khubd and related activity */
1944 hub_quiesce(hub); 1943 hub_quiesce(hub);
1945 1944 return 0;
1946 /* "global suspend" of the downstream HC-to-USB interface */
1947 if (!hdev->parent) {
1948 status = hcd_bus_suspend(hdev->bus);
1949 if (status != 0) {
1950 dev_dbg(&hdev->dev, "'global' suspend %d\n", status);
1951 hub_activate(hub);
1952 }
1953 }
1954 return status;
1955} 1945}
1956 1946
1957static int hub_resume(struct usb_interface *intf) 1947static int hub_resume(struct usb_interface *intf)
1958{ 1948{
1959 struct usb_hub *hub = usb_get_intfdata (intf); 1949 struct usb_hub *hub = usb_get_intfdata (intf);
1960 struct usb_device *hdev = hub->hdev;
1961 int status;
1962 1950
1963 dev_dbg(&intf->dev, "%s\n", __FUNCTION__); 1951 dev_dbg(&intf->dev, "%s\n", __FUNCTION__);
1964 1952
1965 /* "global resume" of the downstream HC-to-USB interface */
1966 if (!hdev->parent) {
1967 struct usb_bus *bus = hdev->bus;
1968 if (bus) {
1969 status = hcd_bus_resume (bus);
1970 if (status) {
1971 dev_dbg(&intf->dev, "'global' resume %d\n",
1972 status);
1973 return status;
1974 }
1975 } else
1976 return -EOPNOTSUPP;
1977 if (status == 0) {
1978 /* TRSMRCY = 10 msec */
1979 msleep(10);
1980 }
1981 }
1982
1983 /* tell khubd to look for changes on this hub */ 1953 /* tell khubd to look for changes on this hub */
1984 hub_activate(hub); 1954 hub_activate(hub);
1985 return 0; 1955 return 0;