From stern@rowland.harvard.edu Thu Oct 13 14:16:26 2005 Date: Thu, 13 Oct 2005 17:08:02 -0400 (EDT) From: Alan Stern To: Greg KH Subject: [PATCH] USB: Rename hcd->hub_suspend to hcd->bus_suspend Message-ID: This patch (as580) is perhaps the only result from the long discussion I had with David about his changes to the root-hub suspend/resume code. It renames the hub_suspend and hub_resume methods in struct usb_hcd to bus_suspend and bus_resume. These are more descriptive names, since the methods really do suspend or resume an entire USB bus, and less likely to be confused with the hub_suspend and hub_resume routines in hub.c. It also takes David's advice about removing the layer of bus glue, where those methods are called. And it implements a related change that David made to the other HCDs but forgot to put into dummy_hcd. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/hcd.c | 16 ++++++---------- drivers/usb/core/hcd.h | 13 +++++++------ drivers/usb/core/hub.c | 8 ++++---- drivers/usb/gadget/dummy_hcd.c | 22 ++++------------------ drivers/usb/host/ehci-hub.c | 8 ++++---- drivers/usb/host/ehci-pci.c | 4 ++-- drivers/usb/host/isp116x-hcd.c | 12 ++++++------ drivers/usb/host/ohci-au1xxx.c | 4 ++-- drivers/usb/host/ohci-hub.c | 6 +++--- drivers/usb/host/ohci-lh7a404.c | 4 ++-- drivers/usb/host/ohci-omap.c | 4 ++-- drivers/usb/host/ohci-pci.c | 4 ++-- drivers/usb/host/ohci-ppc-soc.c | 4 ++-- drivers/usb/host/ohci-pxa27x.c | 4 ++-- drivers/usb/host/ohci-s3c2410.c | 4 ++-- drivers/usb/host/ohci-sa1111.c | 4 ++-- drivers/usb/host/sl811-hcd.c | 16 ++++++++-------- drivers/usb/host/uhci-hcd.c | 4 ++-- 18 files changed, 62 insertions(+), 79 deletions(-) --- gregkh-2.6.orig/drivers/usb/host/ohci-ppc-soc.c +++ gregkh-2.6/drivers/usb/host/ohci-ppc-soc.c @@ -164,8 +164,8 @@ static const struct hc_driver ohci_ppc_s .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, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, #endif .start_port_reset = ohci_start_port_reset, }; --- gregkh-2.6.orig/drivers/usb/core/hub.c +++ gregkh-2.6/drivers/usb/core/hub.c @@ -1917,8 +1917,8 @@ static int hub_suspend(struct usb_interf /* "global suspend" of the downstream HC-to-USB interface */ if (!hdev->parent) { struct usb_bus *bus = hdev->bus; - if (bus && bus->op->hub_suspend) { - int status = bus->op->hub_suspend (bus); + if (bus) { + int status = hcd_bus_suspend (bus); if (status != 0) { dev_dbg(&hdev->dev, "'global' suspend %d\n", @@ -1943,8 +1943,8 @@ static int hub_resume(struct usb_interfa /* "global resume" of the downstream HC-to-USB interface */ if (!hdev->parent) { struct usb_bus *bus = hdev->bus; - if (bus && bus->op->hub_resume) { - status = bus->op->hub_resume (bus); + if (bus) { + status = hcd_bus_resume (bus); if (status) { dev_dbg(&intf->dev, "'global' resume %d\n", status); --- gregkh-2.6.orig/drivers/usb/host/ehci-hub.c +++ gregkh-2.6/drivers/usb/host/ehci-hub.c @@ -30,7 +30,7 @@ #ifdef CONFIG_PM -static int ehci_hub_suspend (struct usb_hcd *hcd) +static int ehci_bus_suspend (struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); int port; @@ -83,7 +83,7 @@ static int ehci_hub_suspend (struct usb_ /* caller has locked the root hub, and should reset/reinit on error */ -static int ehci_hub_resume (struct usb_hcd *hcd) +static int ehci_bus_resume (struct usb_hcd *hcd) { struct ehci_hcd *ehci = hcd_to_ehci (hcd); u32 temp; @@ -166,8 +166,8 @@ static int ehci_hub_resume (struct usb_h #else -#define ehci_hub_suspend NULL -#define ehci_hub_resume NULL +#define ehci_bus_suspend NULL +#define ehci_bus_resume NULL #endif /* CONFIG_PM */ --- gregkh-2.6.orig/drivers/usb/core/hcd.c +++ gregkh-2.6/drivers/usb/core/hcd.c @@ -1433,16 +1433,16 @@ rescan: #ifdef CONFIG_PM -static int hcd_hub_suspend (struct usb_bus *bus) +int hcd_bus_suspend (struct usb_bus *bus) { struct usb_hcd *hcd; int status; hcd = container_of (bus, struct usb_hcd, self); - if (!hcd->driver->hub_suspend) + if (!hcd->driver->bus_suspend) return -ENOENT; hcd->state = HC_STATE_QUIESCING; - status = hcd->driver->hub_suspend (hcd); + status = hcd->driver->bus_suspend (hcd); if (status == 0) hcd->state = HC_STATE_SUSPENDED; else @@ -1451,18 +1451,18 @@ static int hcd_hub_suspend (struct usb_b return status; } -static int hcd_hub_resume (struct usb_bus *bus) +int hcd_bus_resume (struct usb_bus *bus) { struct usb_hcd *hcd; int status; hcd = container_of (bus, struct usb_hcd, self); - if (!hcd->driver->hub_resume) + if (!hcd->driver->bus_resume) return -ENOENT; if (hcd->state == HC_STATE_RUNNING) return 0; hcd->state = HC_STATE_RESUMING; - status = hcd->driver->hub_resume (hcd); + status = hcd->driver->bus_resume (hcd); if (status == 0) hcd->state = HC_STATE_RUNNING; else { @@ -1590,10 +1590,6 @@ static struct usb_operations usb_hcd_ope .buffer_alloc = hcd_buffer_alloc, .buffer_free = hcd_buffer_free, .disable = hcd_endpoint_disable, -#ifdef CONFIG_PM - .hub_suspend = hcd_hub_suspend, - .hub_resume = hcd_hub_resume, -#endif }; /*-------------------------------------------------------------------------*/ --- gregkh-2.6.orig/drivers/usb/host/uhci-hcd.c +++ gregkh-2.6/drivers/usb/host/uhci-hcd.c @@ -804,8 +804,8 @@ static const struct hc_driver uhci_drive #ifdef CONFIG_PM .suspend = uhci_suspend, .resume = uhci_resume, - .hub_suspend = uhci_rh_suspend, - .hub_resume = uhci_rh_resume, + .bus_suspend = uhci_rh_suspend, + .bus_resume = uhci_rh_resume, #endif .stop = uhci_stop, --- gregkh-2.6.orig/drivers/usb/host/ohci-hub.c +++ gregkh-2.6/drivers/usb/host/ohci-hub.c @@ -45,7 +45,7 @@ static void dl_done_list (struct ohci_hc static void finish_unlinks (struct ohci_hcd *, u16 , struct pt_regs *); static int ohci_restart (struct ohci_hcd *ohci); -static int ohci_hub_suspend (struct usb_hcd *hcd) +static int ohci_bus_suspend (struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); int status = 0; @@ -135,7 +135,7 @@ static inline struct ed *find_head (stru } /* caller has locked the root hub */ -static int ohci_hub_resume (struct usb_hcd *hcd) +static int ohci_bus_resume (struct usb_hcd *hcd) { struct ohci_hcd *ohci = hcd_to_ohci (hcd); u32 temp, enables; @@ -362,7 +362,7 @@ done: && usb_trylock_device (hcd->self.root_hub) ) { ohci_vdbg (ohci, "autosuspend\n"); - (void) ohci_hub_suspend (hcd); + (void) ohci_bus_suspend (hcd); usb_unlock_device (hcd->self.root_hub); } #endif --- gregkh-2.6.orig/drivers/usb/host/ehci-pci.c +++ gregkh-2.6/drivers/usb/host/ehci-pci.c @@ -350,8 +350,8 @@ static const struct hc_driver ehci_pci_h */ .hub_status_data = ehci_hub_status_data, .hub_control = ehci_hub_control, - .hub_suspend = ehci_hub_suspend, - .hub_resume = ehci_hub_resume, + .bus_suspend = ehci_bus_suspend, + .bus_resume = ehci_bus_resume, }; /*-------------------------------------------------------------------------*/ --- gregkh-2.6.orig/drivers/usb/core/hcd.h +++ gregkh-2.6/drivers/usb/core/hcd.h @@ -154,10 +154,6 @@ struct usb_operations { void (*disable)(struct usb_device *udev, struct usb_host_endpoint *ep); - - /* global suspend/resume of bus */ - int (*hub_suspend)(struct usb_bus *); - int (*hub_resume)(struct usb_bus *); }; /* each driver provides one of these, and hardware init support */ @@ -212,8 +208,8 @@ struct hc_driver { int (*hub_control) (struct usb_hcd *hcd, u16 typeReq, u16 wValue, u16 wIndex, char *buf, u16 wLength); - int (*hub_suspend)(struct usb_hcd *); - int (*hub_resume)(struct usb_hcd *); + int (*bus_suspend)(struct usb_hcd *); + int (*bus_resume)(struct usb_hcd *); int (*start_port_reset)(struct usb_hcd *, unsigned port_num); void (*hub_irq_enable)(struct usb_hcd *); /* Needed only if port-change IRQs are level-triggered */ @@ -379,6 +375,11 @@ extern int usb_find_interface_driver (st #define usb_endpoint_out(ep_dir) (!((ep_dir) & USB_DIR_IN)) +#ifdef CONFIG_PM +extern int hcd_bus_suspend (struct usb_bus *bus); +extern int hcd_bus_resume (struct usb_bus *bus); +#endif /* CONFIG_PM */ + /* * USB device fs stuff */ --- gregkh-2.6.orig/drivers/usb/host/ohci-omap.c +++ gregkh-2.6/drivers/usb/host/ohci-omap.c @@ -421,8 +421,8 @@ static const struct hc_driver ohci_omap_ .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, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, #endif .start_port_reset = ohci_start_port_reset, }; --- gregkh-2.6.orig/drivers/usb/host/isp116x-hcd.c +++ gregkh-2.6/drivers/usb/host/isp116x-hcd.c @@ -1160,7 +1160,7 @@ static int isp116x_hub_control(struct us #ifdef CONFIG_PM -static int isp116x_hub_suspend(struct usb_hcd *hcd) +static int isp116x_bus_suspend(struct usb_hcd *hcd) { struct isp116x *isp116x = hcd_to_isp116x(hcd); unsigned long flags; @@ -1200,7 +1200,7 @@ static int isp116x_hub_suspend(struct us return ret; } -static int isp116x_hub_resume(struct usb_hcd *hcd) +static int isp116x_bus_resume(struct usb_hcd *hcd) { struct isp116x *isp116x = hcd_to_isp116x(hcd); u32 val; @@ -1266,8 +1266,8 @@ static int isp116x_hub_resume(struct usb #else -#define isp116x_hub_suspend NULL -#define isp116x_hub_resume NULL +#define isp116x_bus_suspend NULL +#define isp116x_bus_resume NULL #endif @@ -1626,8 +1626,8 @@ static struct hc_driver isp116x_hc_drive .hub_status_data = isp116x_hub_status_data, .hub_control = isp116x_hub_control, - .hub_suspend = isp116x_hub_suspend, - .hub_resume = isp116x_hub_resume, + .bus_suspend = isp116x_bus_suspend, + .bus_resume = isp116x_bus_resume, }; /*----------------------------------------------------------------*/ --- gregkh-2.6.orig/drivers/usb/host/ohci-pxa27x.c +++ gregkh-2.6/drivers/usb/host/ohci-pxa27x.c @@ -279,8 +279,8 @@ static const struct hc_driver ohci_pxa27 .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, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, #endif .start_port_reset = ohci_start_port_reset, }; --- gregkh-2.6.orig/drivers/usb/host/ohci-pci.c +++ gregkh-2.6/drivers/usb/host/ohci-pci.c @@ -195,8 +195,8 @@ static const struct hc_driver ohci_pci_h .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, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, #endif .start_port_reset = ohci_start_port_reset, }; --- gregkh-2.6.orig/drivers/usb/host/ohci-lh7a404.c +++ gregkh-2.6/drivers/usb/host/ohci-lh7a404.c @@ -194,8 +194,8 @@ 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, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, #endif .start_port_reset = ohci_start_port_reset, }; --- gregkh-2.6.orig/drivers/usb/host/ohci-au1xxx.c +++ gregkh-2.6/drivers/usb/host/ohci-au1xxx.c @@ -215,8 +215,8 @@ 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, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, #endif .start_port_reset = ohci_start_port_reset, }; --- gregkh-2.6.orig/drivers/usb/host/sl811-hcd.c +++ gregkh-2.6/drivers/usb/host/sl811-hcd.c @@ -1363,7 +1363,7 @@ error: #ifdef CONFIG_PM static int -sl811h_hub_suspend(struct usb_hcd *hcd) +sl811h_bus_suspend(struct usb_hcd *hcd) { // SOFs off DBG("%s\n", __FUNCTION__); @@ -1371,7 +1371,7 @@ sl811h_hub_suspend(struct usb_hcd *hcd) } static int -sl811h_hub_resume(struct usb_hcd *hcd) +sl811h_bus_resume(struct usb_hcd *hcd) { // SOFs on DBG("%s\n", __FUNCTION__); @@ -1380,8 +1380,8 @@ sl811h_hub_resume(struct usb_hcd *hcd) #else -#define sl811h_hub_suspend NULL -#define sl811h_hub_resume NULL +#define sl811h_bus_suspend NULL +#define sl811h_bus_resume NULL #endif @@ -1623,8 +1623,8 @@ static struct hc_driver sl811h_hc_driver */ .hub_status_data = sl811h_hub_status_data, .hub_control = sl811h_hub_control, - .hub_suspend = sl811h_hub_suspend, - .hub_resume = sl811h_hub_resume, + .bus_suspend = sl811h_bus_suspend, + .bus_resume = sl811h_bus_resume, }; /*-------------------------------------------------------------------------*/ @@ -1794,7 +1794,7 @@ sl811h_suspend(struct device *dev, pm_me return retval; if (state.event == PM_EVENT_FREEZE) - retval = sl811h_hub_suspend(hcd); + retval = sl811h_bus_suspend(hcd); else if (state.event == PM_EVENT_SUSPEND) port_power(sl811, 0); if (retval == 0) @@ -1822,7 +1822,7 @@ sl811h_resume(struct device *dev, u32 ph } dev->power.power_state = PMSG_ON; - return sl811h_hub_resume(hcd); + return sl811h_bus_resume(hcd); } #else --- gregkh-2.6.orig/drivers/usb/host/ohci-sa1111.c +++ gregkh-2.6/drivers/usb/host/ohci-sa1111.c @@ -236,8 +236,8 @@ static const struct hc_driver ohci_sa111 .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, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, #endif .start_port_reset = ohci_start_port_reset, }; --- gregkh-2.6.orig/drivers/usb/host/ohci-s3c2410.c +++ gregkh-2.6/drivers/usb/host/ohci-s3c2410.c @@ -449,8 +449,8 @@ static const struct hc_driver ohci_s3c24 .hub_status_data = ohci_s3c2410_hub_status_data, .hub_control = ohci_s3c2410_hub_control, #ifdef CONFIG_PM - .hub_suspend = ohci_hub_suspend, - .hub_resume = ohci_hub_resume, + .bus_suspend = ohci_bus_suspend, + .bus_resume = ohci_bus_resume, #endif .start_port_reset = ohci_start_port_reset, }; --- gregkh-2.6.orig/drivers/usb/gadget/dummy_hcd.c +++ gregkh-2.6/drivers/usb/gadget/dummy_hcd.c @@ -1758,7 +1758,7 @@ static int dummy_hub_control ( return retval; } -static int dummy_hub_suspend (struct usb_hcd *hcd) +static int dummy_bus_suspend (struct usb_hcd *hcd) { struct dummy *dum = hcd_to_dummy (hcd); @@ -1769,7 +1769,7 @@ static int dummy_hub_suspend (struct usb return 0; } -static int dummy_hub_resume (struct usb_hcd *hcd) +static int dummy_bus_resume (struct usb_hcd *hcd) { struct dummy *dum = hcd_to_dummy (hcd); @@ -1901,8 +1901,8 @@ static const struct hc_driver dummy_hcd .hub_status_data = dummy_hub_status, .hub_control = dummy_hub_control, - .hub_suspend = dummy_hub_suspend, - .hub_resume = dummy_hub_resume, + .bus_suspend = dummy_bus_suspend, + .bus_resume = dummy_bus_resume, }; static int dummy_hcd_probe (struct device *dev) @@ -1947,13 +1947,6 @@ static int dummy_hcd_suspend (struct dev dev_dbg (dev, "%s\n", __FUNCTION__); hcd = dev_get_drvdata (dev); -#ifndef CONFIG_USB_SUSPEND - /* Otherwise this would never happen */ - usb_lock_device (hcd->self.root_hub); - dummy_hub_suspend (hcd); - usb_unlock_device (hcd->self.root_hub); -#endif - hcd->state = HC_STATE_SUSPENDED; return 0; } @@ -1969,13 +1962,6 @@ static int dummy_hcd_resume (struct devi hcd = dev_get_drvdata (dev); hcd->state = HC_STATE_RUNNING; -#ifndef CONFIG_USB_SUSPEND - /* Otherwise this would never happen */ - usb_lock_device (hcd->self.root_hub); - dummy_hub_resume (hcd); - usb_unlock_device (hcd->self.root_hub); -#endif - usb_hcd_poll_rh_status (hcd); return 0; }