[PATCH] all HCDs provide root hub suspend/resume methods
This cleans up a small recent FIXME, ensuring that all the HCDs provide
root hub suspend/resume methods. It also wraps the calls to those root
suspend routines just like on the PCI "USB_SUSPEND not defined" cases,
so non-PCI bus glue won't be as tempted to behave very differently.
Several of the SOC based OHCI drivers forgot to list those methods;
the patch also adds those missing declarations.
Signed-off-by: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/usb/core/hcd.c | 42 +++++++++++++++++++++++++---------------
drivers/usb/host/ohci-au1xxx.c | 5 ++++
drivers/usb/host/ohci-lh7a404.c | 5 ++++
drivers/usb/host/ohci-pxa27x.c | 1
drivers/usb/host/ohci-s3c2410.c | 1
drivers/usb/host/ohci-sa1111.c | 1
6 files changed, 40 insertions(+), 15 deletions(-)
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c
index 5e8ade0..375382f 100644
--- a/drivers/usb/core/hcd.c
+++ b/drivers/usb/core/hcd.c
@@ -1431,28 +1431,44 @@
/*-------------------------------------------------------------------------*/
-/* FIXME make this #ifdef CONFIG_PM ... update root hubs, retest */
-
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM
static int hcd_hub_suspend (struct usb_bus *bus)
{
struct usb_hcd *hcd;
+ int status;
hcd = container_of (bus, struct usb_hcd, self);
- if (hcd->driver->hub_suspend)
- return hcd->driver->hub_suspend (hcd);
- return 0;
+ if (!hcd->driver->hub_suspend)
+ return -ENOENT;
+ hcd->state = HC_STATE_QUIESCING;
+ status = hcd->driver->hub_suspend (hcd);
+ if (status == 0)
+ hcd->state = HC_STATE_SUSPENDED;
+ else
+ dev_dbg(&bus->root_hub->dev, "%s fail, err %d\n",
+ "suspend", status);
+ return status;
}
static int hcd_hub_resume (struct usb_bus *bus)
{
struct usb_hcd *hcd;
+ int status;
hcd = container_of (bus, struct usb_hcd, self);
- if (hcd->driver->hub_resume)
- return hcd->driver->hub_resume (hcd);
- return 0;
+ if (!hcd->driver->hub_resume)
+ return -ENOENT;
+ hcd->state = HC_STATE_RESUMING;
+ status = hcd->driver->hub_resume (hcd);
+ if (status == 0)
+ hcd->state = HC_STATE_RUNNING;
+ else {
+ dev_dbg(&bus->root_hub->dev, "%s fail, err %d\n",
+ "resume", status);
+ usb_hc_died(hcd);
+ }
+ return status;
}
/**
@@ -1473,14 +1489,10 @@
usb_resume_root_hub (hcd->self.root_hub);
spin_unlock_irqrestore (&hcd_root_hub_lock, flags);
}
-
-#else
-void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
-{
-}
-#endif
EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
+#endif
+
/*-------------------------------------------------------------------------*/
#ifdef CONFIG_USB_OTG
@@ -1532,7 +1544,7 @@
.buffer_alloc = hcd_buffer_alloc,
.buffer_free = hcd_buffer_free,
.disable = hcd_endpoint_disable,
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM
.hub_suspend = hcd_hub_suspend,
.hub_resume = hcd_hub_resume,
#endif