Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

USB: clarify usage of hcd->suspend/resume methods

The .suspend and .resume method pointers in struct usb_hcd have not
been fully understood by host-controller driver writers. They are
meant for use with PCI controllers; other platform-specific drivers
generally should not refer to them.

To try and clarify matters, this patch (as1065) renames those methods
to .pci_suspend and .pci_resume. It eliminates corresponding dead code
and bogus references in the ohci-ssb and u132-hcd drivers.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
7be7d741 7329e211

+15 -83
+5 -5
drivers/usb/core/hcd-pci.c
··· 215 215 hcd->state == HC_STATE_HALT)) 216 216 return -EBUSY; 217 217 218 - if (hcd->driver->suspend) { 219 - retval = hcd->driver->suspend(hcd, message); 220 - suspend_report_result(hcd->driver->suspend, retval); 218 + if (hcd->driver->pci_suspend) { 219 + retval = hcd->driver->pci_suspend(hcd, message); 220 + suspend_report_result(hcd->driver->pci_suspend, retval); 221 221 if (retval) 222 222 goto done; 223 223 } ··· 405 405 406 406 clear_bit(HCD_FLAG_SAW_IRQ, &hcd->flags); 407 407 408 - if (hcd->driver->resume) { 409 - retval = hcd->driver->resume(hcd); 408 + if (hcd->driver->pci_resume) { 409 + retval = hcd->driver->pci_resume(hcd); 410 410 if (retval) { 411 411 dev_err(hcd->self.controller, 412 412 "PCI post-resume error %d!\n", retval);
+2 -2
drivers/usb/core/hcd.h
··· 178 178 * a whole, not just the root hub; they're for PCI bus glue. 179 179 */ 180 180 /* called after suspending the hub, before entering D3 etc */ 181 - int (*suspend) (struct usb_hcd *hcd, pm_message_t message); 181 + int (*pci_suspend) (struct usb_hcd *hcd, pm_message_t message); 182 182 183 183 /* called after entering D0 (etc), before resuming the hub */ 184 - int (*resume) (struct usb_hcd *hcd); 184 + int (*pci_resume) (struct usb_hcd *hcd); 185 185 186 186 /* cleanly make HCD stop writing memory and doing I/O */ 187 187 void (*stop) (struct usb_hcd *hcd);
+2 -2
drivers/usb/host/ehci-pci.c
··· 353 353 .reset = ehci_pci_setup, 354 354 .start = ehci_run, 355 355 #ifdef CONFIG_PM 356 - .suspend = ehci_pci_suspend, 357 - .resume = ehci_pci_resume, 356 + .pci_suspend = ehci_pci_suspend, 357 + .pci_resume = ehci_pci_resume, 358 358 #endif 359 359 .stop = ehci_stop, 360 360 .shutdown = ehci_shutdown,
+2 -3
drivers/usb/host/ohci-pci.c
··· 347 347 .shutdown = ohci_shutdown, 348 348 349 349 #ifdef CONFIG_PM 350 - /* these suspend/resume entries are for upstream PCI glue ONLY */ 351 - .suspend = ohci_pci_suspend, 352 - .resume = ohci_pci_resume, 350 + .pci_suspend = ohci_pci_suspend, 351 + .pci_resume = ohci_pci_resume, 353 352 #endif 354 353 355 354 /*
-35
drivers/usb/host/ohci-ssb.c
··· 60 60 return err; 61 61 } 62 62 63 - #ifdef CONFIG_PM 64 - static int ssb_ohci_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) 65 - { 66 - struct ssb_ohci_device *ohcidev = hcd_to_ssb_ohci(hcd); 67 - struct ohci_hcd *ohci = &ohcidev->ohci; 68 - unsigned long flags; 69 - 70 - spin_lock_irqsave(&ohci->lock, flags); 71 - 72 - ohci_writel(ohci, OHCI_INTR_MIE, &ohci->regs->intrdisable); 73 - ohci_readl(ohci, &ohci->regs->intrdisable); /* commit write */ 74 - 75 - /* make sure snapshot being resumed re-enumerates everything */ 76 - if (message.event == PM_EVENT_PRETHAW) 77 - ohci_usb_reset(ohci); 78 - 79 - clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 80 - 81 - spin_unlock_irqrestore(&ohci->lock, flags); 82 - return 0; 83 - } 84 - 85 - static int ssb_ohci_hcd_resume(struct usb_hcd *hcd) 86 - { 87 - set_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); 88 - usb_hcd_resume_root_hub(hcd); 89 - return 0; 90 - } 91 - #endif /* CONFIG_PM */ 92 - 93 63 static const struct hc_driver ssb_ohci_hc_driver = { 94 64 .description = "ssb-usb-ohci", 95 65 .product_desc = "SSB OHCI Controller", ··· 72 102 .start = ssb_ohci_start, 73 103 .stop = ohci_stop, 74 104 .shutdown = ohci_shutdown, 75 - 76 - #ifdef CONFIG_PM 77 - .suspend = ssb_ohci_hcd_suspend, 78 - .resume = ssb_ohci_hcd_resume, 79 - #endif 80 105 81 106 .urb_enqueue = ohci_urb_enqueue, 82 107 .urb_dequeue = ohci_urb_dequeue,
-32
drivers/usb/host/u132-hcd.c
··· 2946 2946 2947 2947 2948 2948 #ifdef CONFIG_PM 2949 - static int u132_hcd_suspend(struct usb_hcd *hcd, pm_message_t message) 2950 - { 2951 - struct u132 *u132 = hcd_to_u132(hcd); 2952 - if (u132->going > 1) { 2953 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2954 - , u132->going); 2955 - return -ENODEV; 2956 - } else if (u132->going > 0) { 2957 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2958 - return -ESHUTDOWN; 2959 - } else 2960 - return 0; 2961 - } 2962 - 2963 - static int u132_hcd_resume(struct usb_hcd *hcd) 2964 - { 2965 - struct u132 *u132 = hcd_to_u132(hcd); 2966 - if (u132->going > 1) { 2967 - dev_err(&u132->platform_dev->dev, "device has been removed %d\n" 2968 - , u132->going); 2969 - return -ENODEV; 2970 - } else if (u132->going > 0) { 2971 - dev_err(&u132->platform_dev->dev, "device is being removed\n"); 2972 - return -ESHUTDOWN; 2973 - } else 2974 - return 0; 2975 - } 2976 - 2977 2949 static int u132_bus_suspend(struct usb_hcd *hcd) 2978 2950 { 2979 2951 struct u132 *u132 = hcd_to_u132(hcd); ··· 2975 3003 } 2976 3004 2977 3005 #else 2978 - #define u132_hcd_suspend NULL 2979 - #define u132_hcd_resume NULL 2980 3006 #define u132_bus_suspend NULL 2981 3007 #define u132_bus_resume NULL 2982 3008 #endif ··· 2985 3015 .flags = HCD_USB11 | HCD_MEMORY, 2986 3016 .reset = u132_hcd_reset, 2987 3017 .start = u132_hcd_start, 2988 - .suspend = u132_hcd_suspend, 2989 - .resume = u132_hcd_resume, 2990 3018 .stop = u132_hcd_stop, 2991 3019 .urb_enqueue = u132_urb_enqueue, 2992 3020 .urb_dequeue = u132_urb_dequeue,
+4 -4
drivers/usb/host/uhci-hcd.c
··· 737 737 return rc; 738 738 } 739 739 740 - static int uhci_suspend(struct usb_hcd *hcd, pm_message_t message) 740 + static int uhci_pci_suspend(struct usb_hcd *hcd, pm_message_t message) 741 741 { 742 742 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 743 743 int rc = 0; ··· 774 774 return rc; 775 775 } 776 776 777 - static int uhci_resume(struct usb_hcd *hcd) 777 + static int uhci_pci_resume(struct usb_hcd *hcd) 778 778 { 779 779 struct uhci_hcd *uhci = hcd_to_uhci(hcd); 780 780 ··· 872 872 .reset = uhci_init, 873 873 .start = uhci_start, 874 874 #ifdef CONFIG_PM 875 - .suspend = uhci_suspend, 876 - .resume = uhci_resume, 875 + .pci_suspend = uhci_pci_suspend, 876 + .pci_resume = uhci_pci_resume, 877 877 .bus_suspend = uhci_rh_suspend, 878 878 .bus_resume = uhci_rh_resume, 879 879 #endif