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

USB: remove CONFIG_USB_SUSPEND option

This patch (as1675) removes the CONFIG_USB_SUSPEND option, essentially
replacing it everywhere with CONFIG_PM_RUNTIME (except for one place
in hub.c, where it is replaced with CONFIG_PM because the code needs
to be used in both runtime and system PM). The net result is code
shrinkage and simplification.

There's very little point in keeping CONFIG_USB_SUSPEND because almost
everybody enables it. The few that don't will find that the usbcore
module has gotten somewhat bigger and they will have to take active
measures if they want to prevent hubs from being runtime suspended.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Peter Chen <peter.chen@freescale.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
84ebc102 0aa2832d

+35 -94
-16
drivers/usb/core/Kconfig
··· 38 38 39 39 If you are unsure about this, say N here. 40 40 41 - config USB_SUSPEND 42 - bool "USB runtime power management (autosuspend) and wakeup" 43 - depends on USB && PM_RUNTIME 44 - help 45 - If you say Y here, you can use driver calls or the sysfs 46 - "power/control" file to enable or disable autosuspend for 47 - individual USB peripherals (see 48 - Documentation/usb/power-management.txt for more details). 49 - 50 - Also, USB "remote wakeup" signaling is supported, whereby some 51 - USB devices (like keyboards and network adapters) can wake up 52 - their parent hub. That wakeup cascades up the USB tree, and 53 - could wake the system from states like suspend-to-RAM. 54 - 55 - If you are unsure about this, say N here. 56 - 57 41 config USB_OTG 58 42 bool "OTG support" 59 43 depends on USB
+2 -2
drivers/usb/core/driver.c
··· 1412 1412 1413 1413 #endif /* CONFIG_PM */ 1414 1414 1415 - #ifdef CONFIG_USB_SUSPEND 1415 + #ifdef CONFIG_PM_RUNTIME 1416 1416 1417 1417 /** 1418 1418 * usb_enable_autosuspend - allow a USB device to be autosuspended ··· 1780 1780 return ret; 1781 1781 } 1782 1782 1783 - #endif /* CONFIG_USB_SUSPEND */ 1783 + #endif /* CONFIG_PM_RUNTIME */ 1784 1784 1785 1785 struct bus_type usb_bus_type = { 1786 1786 .name = "usb",
+5 -5
drivers/usb/core/hcd.c
··· 2125 2125 2126 2126 #endif /* CONFIG_PM */ 2127 2127 2128 - #ifdef CONFIG_USB_SUSPEND 2128 + #ifdef CONFIG_PM_RUNTIME 2129 2129 2130 2130 /* Workqueue routine for root-hub remote wakeup */ 2131 2131 static void hcd_resume_work(struct work_struct *work) ··· 2160 2160 } 2161 2161 EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub); 2162 2162 2163 - #endif /* CONFIG_USB_SUSPEND */ 2163 + #endif /* CONFIG_PM_RUNTIME */ 2164 2164 2165 2165 /*-------------------------------------------------------------------------*/ 2166 2166 ··· 2336 2336 init_timer(&hcd->rh_timer); 2337 2337 hcd->rh_timer.function = rh_timer_func; 2338 2338 hcd->rh_timer.data = (unsigned long) hcd; 2339 - #ifdef CONFIG_USB_SUSPEND 2339 + #ifdef CONFIG_PM_RUNTIME 2340 2340 INIT_WORK(&hcd->wakeup_work, hcd_resume_work); 2341 2341 #endif 2342 2342 ··· 2590 2590 hcd->rh_registered = 0; 2591 2591 spin_unlock_irq(&hcd_root_hub_lock); 2592 2592 2593 - #ifdef CONFIG_USB_SUSPEND 2593 + #ifdef CONFIG_PM_RUNTIME 2594 2594 cancel_work_sync(&hcd->wakeup_work); 2595 2595 #endif 2596 2596 mutex_lock(&usb_bus_list_lock); ··· 2645 2645 hcd->rh_registered = 0; 2646 2646 spin_unlock_irq (&hcd_root_hub_lock); 2647 2647 2648 - #ifdef CONFIG_USB_SUSPEND 2648 + #ifdef CONFIG_PM_RUNTIME 2649 2649 cancel_work_sync(&hcd->wakeup_work); 2650 2650 #endif 2651 2651
+7 -35
drivers/usb/core/hub.c
··· 2827 2827 } 2828 2828 EXPORT_SYMBOL_GPL(usb_enable_ltm); 2829 2829 2830 - #ifdef CONFIG_USB_SUSPEND 2830 + #ifdef CONFIG_PM 2831 2831 /* 2832 2832 * usb_disable_function_remotewakeup - disable usb3.0 2833 2833 * device's function remote wakeup ··· 2886 2886 * Linux (2.6) currently has NO mechanisms to initiate that: no khubd 2887 2887 * timer, no SRP, no requests through sysfs. 2888 2888 * 2889 - * If CONFIG_USB_SUSPEND isn't enabled, non-SuperSpeed devices really get 2889 + * If Runtime PM isn't enabled or used, non-SuperSpeed devices really get 2890 2890 * suspended only when their bus goes into global suspend (i.e., the root 2891 2891 * hub is suspended). Nevertheless, we change @udev->state to 2892 2892 * USB_STATE_SUSPENDED as this is the device's "logical" state. The actual ··· 3247 3247 return status; 3248 3248 } 3249 3249 3250 + #endif /* CONFIG_PM */ 3251 + 3252 + #ifdef CONFIG_PM_RUNTIME 3253 + 3250 3254 /* caller has locked udev */ 3251 3255 int usb_remote_wakeup(struct usb_device *udev) 3252 3256 { ··· 3263 3259 /* Let the drivers do their thing, then... */ 3264 3260 usb_autosuspend_device(udev); 3265 3261 } 3266 - } 3267 - return status; 3268 - } 3269 - 3270 - #else /* CONFIG_USB_SUSPEND */ 3271 - 3272 - /* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */ 3273 - 3274 - int usb_port_suspend(struct usb_device *udev, pm_message_t msg) 3275 - { 3276 - return 0; 3277 - } 3278 - 3279 - /* However we may need to do a reset-resume */ 3280 - 3281 - int usb_port_resume(struct usb_device *udev, pm_message_t msg) 3282 - { 3283 - struct usb_hub *hub = usb_hub_to_struct_hub(udev->parent); 3284 - int port1 = udev->portnum; 3285 - int status; 3286 - u16 portchange, portstatus; 3287 - 3288 - status = hub_port_status(hub, port1, &portstatus, &portchange); 3289 - status = check_port_resume_type(udev, 3290 - hub, port1, status, portchange, portstatus); 3291 - 3292 - if (status) { 3293 - dev_dbg(&udev->dev, "can't resume, status %d\n", status); 3294 - hub_port_logical_disconnect(hub, port1); 3295 - } else if (udev->reset_resume) { 3296 - dev_dbg(&udev->dev, "reset-resume\n"); 3297 - status = usb_reset_and_verify_device(udev); 3298 3262 } 3299 3263 return status; 3300 3264 } ··· 4328 4356 if (portstatus & USB_PORT_STAT_ENABLE) { 4329 4357 status = 0; /* Nothing to do */ 4330 4358 4331 - #ifdef CONFIG_USB_SUSPEND 4359 + #ifdef CONFIG_PM_RUNTIME 4332 4360 } else if (udev->state == USB_STATE_SUSPENDED && 4333 4361 udev->persist_enabled) { 4334 4362 /* For a suspended device, treat this as a
+2 -2
drivers/usb/core/port.c
··· 71 71 kfree(port_dev); 72 72 } 73 73 74 - #ifdef CONFIG_USB_SUSPEND 74 + #ifdef CONFIG_PM_RUNTIME 75 75 static int usb_port_runtime_resume(struct device *dev) 76 76 { 77 77 struct usb_port *port_dev = to_usb_port(dev); ··· 139 139 #endif 140 140 141 141 static const struct dev_pm_ops usb_port_pm_ops = { 142 - #ifdef CONFIG_USB_SUSPEND 142 + #ifdef CONFIG_PM_RUNTIME 143 143 .runtime_suspend = usb_port_runtime_suspend, 144 144 .runtime_resume = usb_port_runtime_resume, 145 145 .runtime_idle = pm_generic_runtime_idle,
+2 -2
drivers/usb/core/sysfs.c
··· 338 338 339 339 #endif /* CONFIG_PM */ 340 340 341 - #ifdef CONFIG_USB_SUSPEND 341 + #ifdef CONFIG_PM_RUNTIME 342 342 343 343 static ssize_t 344 344 show_connected_duration(struct device *dev, struct device_attribute *attr, ··· 544 544 #define add_power_attributes(dev) 0 545 545 #define remove_power_attributes(dev) do {} while (0) 546 546 547 - #endif /* CONFIG_USB_SUSPEND */ 547 + #endif /* CONFIG_PM_RUNTIME */ 548 548 549 549 550 550 /* Descriptor fields */
+2 -2
drivers/usb/core/usb.c
··· 49 49 50 50 static bool nousb; /* Disable USB when built into kernel image */ 51 51 52 - #ifdef CONFIG_USB_SUSPEND 52 + #ifdef CONFIG_PM_RUNTIME 53 53 static int usb_autosuspend_delay = 2; /* Default delay value, 54 54 * in seconds */ 55 55 module_param_named(autosuspend, usb_autosuspend_delay, int, 0644); ··· 307 307 .thaw = usb_dev_thaw, 308 308 .poweroff = usb_dev_poweroff, 309 309 .restore = usb_dev_restore, 310 - #ifdef CONFIG_USB_SUSPEND 310 + #ifdef CONFIG_PM_RUNTIME 311 311 .runtime_suspend = usb_runtime_suspend, 312 312 .runtime_resume = usb_runtime_resume, 313 313 .runtime_idle = usb_runtime_idle,
+1 -1
drivers/usb/core/usb.h
··· 93 93 94 94 #endif 95 95 96 - #ifdef CONFIG_USB_SUSPEND 96 + #ifdef CONFIG_PM_RUNTIME 97 97 98 98 extern void usb_autosuspend_device(struct usb_device *udev); 99 99 extern int usb_autoresume_device(struct usb_device *udev);
+1 -11
drivers/usb/host/ehci-pci.c
··· 292 292 } 293 293 } 294 294 295 - #ifdef CONFIG_USB_SUSPEND 296 - /* REVISIT: the controller works fine for wakeup iff the root hub 297 - * itself is "globally" suspended, but usbcore currently doesn't 298 - * understand such things. 299 - * 300 - * System suspend currently expects to be able to suspend the entire 301 - * device tree, device-at-a-time. If we failed selective suspend 302 - * reports, system suspend would fail; so the root hub code must claim 303 - * success. That's lying to usbcore, and it matters for runtime 304 - * PM scenarios with selective suspend and remote wakeup... 305 - */ 295 + #ifdef CONFIG_PM_RUNTIME 306 296 if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev)) 307 297 ehci_warn(ehci, "selective suspend/wakeup unavailable\n"); 308 298 #endif
-6
drivers/usb/host/ohci-hub.c
··· 580 580 581 581 /* See usb 7.1.7.5: root hubs must issue at least 50 msec reset signaling, 582 582 * not necessarily continuous ... to guard against resume signaling. 583 - * The short timeout is safe for non-root hubs, and is backward-compatible 584 - * with earlier Linux hosts. 585 583 */ 586 - #ifdef CONFIG_USB_SUSPEND 587 584 #define PORT_RESET_MSEC 50 588 - #else 589 - #define PORT_RESET_MSEC 10 590 - #endif 591 585 592 586 /* this timer value might be vendor-specific ... */ 593 587 #define PORT_RESET_HW_MSEC 10
+1 -1
drivers/usb/host/sl811-hcd.c
··· 1755 1755 1756 1756 /* for this device there's no useful distinction between the controller 1757 1757 * and its root hub, except that the root hub only gets direct PM calls 1758 - * when CONFIG_USB_SUSPEND is enabled. 1758 + * when CONFIG_PM_RUNTIME is enabled. 1759 1759 */ 1760 1760 1761 1761 static int
+5 -4
drivers/usb/host/u132-hcd.c
··· 3141 3141 3142 3142 3143 3143 #ifdef CONFIG_PM 3144 - /* for this device there's no useful distinction between the controller 3145 - * and its root hub, except that the root hub only gets direct PM calls 3146 - * when CONFIG_USB_SUSPEND is enabled. 3147 - */ 3144 + /* 3145 + * for this device there's no useful distinction between the controller 3146 + * and its root hub, except that the root hub only gets direct PM calls 3147 + * when CONFIG_PM_RUNTIME is enabled. 3148 + */ 3148 3149 static int u132_suspend(struct platform_device *pdev, pm_message_t state) 3149 3150 { 3150 3151 struct usb_hcd *hcd = platform_get_drvdata(pdev);
+1 -1
drivers/usb/host/xhci-hub.c
··· 1075 1075 set_bit(port_index, &bus_state->bus_suspended); 1076 1076 } 1077 1077 /* USB core sets remote wake mask for USB 3.0 hubs, 1078 - * including the USB 3.0 roothub, but only if CONFIG_USB_SUSPEND 1078 + * including the USB 3.0 roothub, but only if CONFIG_PM_RUNTIME 1079 1079 * is enabled, so also enable remote wake here. 1080 1080 */ 1081 1081 if (hcd->self.root_hub->do_remote_wakeup) {
+2 -2
drivers/usb/host/xhci.c
··· 3801 3801 return raw_port; 3802 3802 } 3803 3803 3804 - #ifdef CONFIG_USB_SUSPEND 3804 + #ifdef CONFIG_PM_RUNTIME 3805 3805 3806 3806 /* BESL to HIRD Encoding array for USB2 LPM */ 3807 3807 static int xhci_besl_encoding[16] = {125, 150, 200, 300, 400, 500, 1000, 2000, ··· 4051 4051 return 0; 4052 4052 } 4053 4053 4054 - #endif /* CONFIG_USB_SUSPEND */ 4054 + #endif /* CONFIG_PM_RUNTIME */ 4055 4055 4056 4056 /*---------------------- USB 3.0 Link PM functions ------------------------*/ 4057 4057
+1 -1
include/linux/usb.h
··· 617 617 #endif 618 618 619 619 /* USB autosuspend and autoresume */ 620 - #ifdef CONFIG_USB_SUSPEND 620 + #ifdef CONFIG_PM_RUNTIME 621 621 extern void usb_enable_autosuspend(struct usb_device *udev); 622 622 extern void usb_disable_autosuspend(struct usb_device *udev); 623 623
+3 -3
include/linux/usb/hcd.h
··· 84 84 85 85 struct timer_list rh_timer; /* drives root-hub polling */ 86 86 struct urb *status_urb; /* the current status urb */ 87 - #ifdef CONFIG_USB_SUSPEND 87 + #ifdef CONFIG_PM_RUNTIME 88 88 struct work_struct wakeup_work; /* for remote wakeup */ 89 89 #endif 90 90 ··· 593 593 extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg); 594 594 #endif /* CONFIG_PM */ 595 595 596 - #ifdef CONFIG_USB_SUSPEND 596 + #ifdef CONFIG_PM_RUNTIME 597 597 extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd); 598 598 #else 599 599 static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd) 600 600 { 601 601 return; 602 602 } 603 - #endif /* CONFIG_USB_SUSPEND */ 603 + #endif /* CONFIG_PM_RUNTIME */ 604 604 605 605 /*-------------------------------------------------------------------------*/ 606 606