This just connecting the dots using existing code that
previously wasn't always enabled.


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 <[EMAIL PROTECTED]>

--- g26.orig/drivers/usb/core/hcd.c	2005-09-22 22:14:43.000000000 -0700
+++ g26/drivers/usb/core/hcd.c	2005-09-22 22:15:13.000000000 -0700
@@ -1430,28 +1430,44 @@ rescan:
 
 /*-------------------------------------------------------------------------*/
 
-/* 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;
 }
 
 /**
@@ -1472,13 +1488,9 @@ void usb_hcd_resume_root_hub (struct usb
 		usb_resume_root_hub (hcd->self.root_hub);
 	spin_unlock_irqrestore (&hcd_root_hub_lock, flags);
 }
+EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
 
-#else
-void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
-{
-}
 #endif
-EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
 
 /*-------------------------------------------------------------------------*/
 
@@ -1531,7 +1543,7 @@ static struct usb_operations usb_hcd_ope
 	.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
--- g26.orig/drivers/usb/host/ohci-lh7a404.c	2005-09-22 22:12:36.000000000 -0700
+++ g26/drivers/usb/host/ohci-lh7a404.c	2005-09-22 22:15:13.000000000 -0700
@@ -195,6 +195,11 @@ static const struct hc_driver ohci_lh7a4
 	 */
 	.hub_status_data =	ohci_hub_status_data,
 	.hub_control =		ohci_hub_control,
+#ifdef	CONFIG_PM
+	.hub_suspend =		ohci_hub_suspend,
+	.hub_resume =		ohci_hub_resume,
+#endif
+	.start_port_reset =	ohci_start_port_reset,
 };
 
 /*-------------------------------------------------------------------------*/
--- g26.orig/drivers/usb/host/ohci-s3c2410.c	2005-09-22 22:14:43.000000000 -0700
+++ g26/drivers/usb/host/ohci-s3c2410.c	2005-09-22 22:15:13.000000000 -0700
@@ -453,6 +453,7 @@ static const struct hc_driver ohci_s3c24
 	.hub_suspend =		ohci_hub_suspend,
 	.hub_resume =		ohci_hub_resume,
 #endif
+	.start_port_reset =	ohci_start_port_reset,
 };
 
 /* device driver */
--- g26.orig/drivers/usb/host/ohci-sa1111.c	2005-09-22 22:14:43.000000000 -0700
+++ g26/drivers/usb/host/ohci-sa1111.c	2005-09-22 22:15:13.000000000 -0700
@@ -239,6 +239,7 @@ static const struct hc_driver ohci_sa111
 	.hub_suspend =		ohci_hub_suspend,
 	.hub_resume =		ohci_hub_resume,
 #endif
+	.start_port_reset =	ohci_start_port_reset,
 };
 
 /*-------------------------------------------------------------------------*/
--- g26.orig/drivers/usb/host/ohci-pxa27x.c	2005-09-22 22:14:43.000000000 -0700
+++ g26/drivers/usb/host/ohci-pxa27x.c	2005-09-22 22:15:13.000000000 -0700
@@ -282,6 +282,7 @@ static const struct hc_driver ohci_pxa27
 	.hub_suspend =		ohci_hub_suspend,
 	.hub_resume =		ohci_hub_resume,
 #endif
+	.start_port_reset =	ohci_start_port_reset,
 };
 
 /*-------------------------------------------------------------------------*/
--- g26.orig/drivers/usb/host/ohci-au1xxx.c	2005-09-22 22:12:36.000000000 -0700
+++ g26/drivers/usb/host/ohci-au1xxx.c	2005-09-22 22:15:13.000000000 -0700
@@ -214,6 +214,11 @@ static const struct hc_driver ohci_au1xx
 	 */
 	.hub_status_data =	ohci_hub_status_data,
 	.hub_control =		ohci_hub_control,
+#ifdef	CONFIG_PM
+	.hub_suspend =		ohci_hub_suspend,
+	.hub_resume =		ohci_hub_resume,
+#endif
+	.start_port_reset =	ohci_start_port_reset,
 };
 
 /*-------------------------------------------------------------------------*/

Reply via email to