USB: remove CONFIG_USB_SUSPEND option
authorAlan Stern <stern@rowland.harvard.edu>
Wed, 27 Mar 2013 20:14:46 +0000 (16:14 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 28 Mar 2013 18:10:22 +0000 (11:10 -0700)
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>
16 files changed:
drivers/usb/core/Kconfig
drivers/usb/core/driver.c
drivers/usb/core/hcd.c
drivers/usb/core/hub.c
drivers/usb/core/port.c
drivers/usb/core/sysfs.c
drivers/usb/core/usb.c
drivers/usb/core/usb.h
drivers/usb/host/ehci-pci.c
drivers/usb/host/ohci-hub.c
drivers/usb/host/sl811-hcd.c
drivers/usb/host/u132-hcd.c
drivers/usb/host/xhci-hub.c
drivers/usb/host/xhci.c
include/linux/usb.h
include/linux/usb/hcd.h

index f70c1a1694ade4237e7ec7fee06f6c1342e46af1..175701a2dae4614658a50ff95b4771ae2ab70e85 100644 (file)
@@ -38,22 +38,6 @@ config USB_DYNAMIC_MINORS
 
          If you are unsure about this, say N here.
 
-config USB_SUSPEND
-       bool "USB runtime power management (autosuspend) and wakeup"
-       depends on USB && PM_RUNTIME
-       help
-         If you say Y here, you can use driver calls or the sysfs
-         "power/control" file to enable or disable autosuspend for
-         individual USB peripherals (see
-         Documentation/usb/power-management.txt for more details).
-
-         Also, USB "remote wakeup" signaling is supported, whereby some
-         USB devices (like keyboards and network adapters) can wake up
-         their parent hub.  That wakeup cascades up the USB tree, and
-         could wake the system from states like suspend-to-RAM.
-
-         If you are unsure about this, say N here.
-
 config USB_OTG
        bool "OTG support"
        depends on USB
index eb1d00a3543a4334d03cd59b1868f97d6c94ea69..84d2b05858102c926fd93f98aa7d8347927f3c09 100644 (file)
@@ -1412,7 +1412,7 @@ int usb_resume(struct device *dev, pm_message_t msg)
 
 #endif /* CONFIG_PM */
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 
 /**
  * usb_enable_autosuspend - allow a USB device to be autosuspended
@@ -1780,7 +1780,7 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
        return ret;
 }
 
-#endif /* CONFIG_USB_SUSPEND */
+#endif /* CONFIG_PM_RUNTIME */
 
 struct bus_type usb_bus_type = {
        .name =         "usb",
index f9ec44cbb82fb1ff6fa8e620367de8a9daec2c70..d53547d2e4c744c92b43ce55883351aa241f8fb4 100644 (file)
@@ -2125,7 +2125,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
 
 #endif /* CONFIG_PM */
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 
 /* Workqueue routine for root-hub remote wakeup */
 static void hcd_resume_work(struct work_struct *work)
@@ -2160,7 +2160,7 @@ void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
 }
 EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);
 
-#endif /* CONFIG_USB_SUSPEND */
+#endif /* CONFIG_PM_RUNTIME */
 
 /*-------------------------------------------------------------------------*/
 
@@ -2336,7 +2336,7 @@ struct usb_hcd *usb_create_shared_hcd(const struct hc_driver *driver,
        init_timer(&hcd->rh_timer);
        hcd->rh_timer.function = rh_timer_func;
        hcd->rh_timer.data = (unsigned long) hcd;
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
        INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
 #endif
 
@@ -2590,7 +2590,7 @@ error_create_attr_group:
        hcd->rh_registered = 0;
        spin_unlock_irq(&hcd_root_hub_lock);
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
        cancel_work_sync(&hcd->wakeup_work);
 #endif
        mutex_lock(&usb_bus_list_lock);
@@ -2645,7 +2645,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
        hcd->rh_registered = 0;
        spin_unlock_irq (&hcd_root_hub_lock);
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
        cancel_work_sync(&hcd->wakeup_work);
 #endif
 
index 443d5cc9330bcf49e9e8d9ba7ddf553a7cb48e7b..feef9351463d99845a379ee3cdd1cb32b6772a4c 100644 (file)
@@ -2827,7 +2827,7 @@ void usb_enable_ltm(struct usb_device *udev)
 }
 EXPORT_SYMBOL_GPL(usb_enable_ltm);
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM
 /*
  * usb_disable_function_remotewakeup - disable usb3.0
  * device's function remote wakeup
@@ -2886,7 +2886,7 @@ static int usb_disable_function_remotewakeup(struct usb_device *udev)
  * Linux (2.6) currently has NO mechanisms to initiate that:  no khubd
  * timer, no SRP, no requests through sysfs.
  *
- * If CONFIG_USB_SUSPEND isn't enabled, non-SuperSpeed devices really get
+ * If Runtime PM isn't enabled or used, non-SuperSpeed devices really get
  * suspended only when their bus goes into global suspend (i.e., the root
  * hub is suspended).  Nevertheless, we change @udev->state to
  * USB_STATE_SUSPENDED as this is the device's "logical" state.  The actual
@@ -3247,6 +3247,10 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
        return status;
 }
 
+#endif /* CONFIG_PM */
+
+#ifdef CONFIG_PM_RUNTIME
+
 /* caller has locked udev */
 int usb_remote_wakeup(struct usb_device *udev)
 {
@@ -3263,38 +3267,6 @@ int usb_remote_wakeup(struct usb_device *udev)
        return status;
 }
 
-#else  /* CONFIG_USB_SUSPEND */
-
-/* When CONFIG_USB_SUSPEND isn't set, we never suspend or resume any ports. */
-
-int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
-{
-       return 0;
-}
-
-/* However we may need to do a reset-resume */
-
-int usb_port_resume(struct usb_device *udev, pm_message_t msg)
-{
-       struct usb_hub  *hub = usb_hub_to_struct_hub(udev->parent);
-       int             port1 = udev->portnum;
-       int             status;
-       u16             portchange, portstatus;
-
-       status = hub_port_status(hub, port1, &portstatus, &portchange);
-       status = check_port_resume_type(udev,
-                       hub, port1, status, portchange, portstatus);
-
-       if (status) {
-               dev_dbg(&udev->dev, "can't resume, status %d\n", status);
-               hub_port_logical_disconnect(hub, port1);
-       } else if (udev->reset_resume) {
-               dev_dbg(&udev->dev, "reset-resume\n");
-               status = usb_reset_and_verify_device(udev);
-       }
-       return status;
-}
-
 #endif
 
 static int check_ports_changed(struct usb_hub *hub)
@@ -4356,7 +4328,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
                if (portstatus & USB_PORT_STAT_ENABLE) {
                        status = 0;             /* Nothing to do */
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
                } else if (udev->state == USB_STATE_SUSPENDED &&
                                udev->persist_enabled) {
                        /* For a suspended device, treat this as a
index 797f9d51473298582d166858b30e5e464ee2b18c..06c4894bf181bddb3e6d2c86a48dc90fa584917a 100644 (file)
@@ -71,7 +71,7 @@ static void usb_port_device_release(struct device *dev)
        kfree(port_dev);
 }
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 static int usb_port_runtime_resume(struct device *dev)
 {
        struct usb_port *port_dev = to_usb_port(dev);
@@ -139,7 +139,7 @@ static int usb_port_runtime_suspend(struct device *dev)
 #endif
 
 static const struct dev_pm_ops usb_port_pm_ops = {
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
        .runtime_suspend =      usb_port_runtime_suspend,
        .runtime_resume =       usb_port_runtime_resume,
        .runtime_idle =         pm_generic_runtime_idle,
index 3f81a3dc6867638a17ab4b0e2850aa1d79ec33c3..aa38db44818a99ab9331c11d2c670669d014498f 100644 (file)
@@ -338,7 +338,7 @@ static void remove_persist_attributes(struct device *dev)
 
 #endif /* CONFIG_PM */
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 
 static ssize_t
 show_connected_duration(struct device *dev, struct device_attribute *attr,
@@ -544,7 +544,7 @@ static void remove_power_attributes(struct device *dev)
 #define add_power_attributes(dev)      0
 #define remove_power_attributes(dev)   do {} while (0)
 
-#endif /* CONFIG_USB_SUSPEND */
+#endif /* CONFIG_PM_RUNTIME */
 
 
 /* Descriptor fields */
index f81b92572735449b53e5c464ca12d38b314e1029..03eb7ae8fc1a3401e580d78af7a2fee1c4fe9a93 100644 (file)
@@ -49,7 +49,7 @@ const char *usbcore_name = "usbcore";
 
 static bool nousb;     /* Disable USB when built into kernel image */
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 static int usb_autosuspend_delay = 2;          /* Default delay value,
                                                 * in seconds */
 module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
@@ -307,7 +307,7 @@ static const struct dev_pm_ops usb_device_pm_ops = {
        .thaw =         usb_dev_thaw,
        .poweroff =     usb_dev_poweroff,
        .restore =      usb_dev_restore,
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
        .runtime_suspend =      usb_runtime_suspend,
        .runtime_resume =       usb_runtime_resume,
        .runtime_idle =         usb_runtime_idle,
index a7f20bde0e5e2a18d202a346b1e4024af28fd796..823857767a16f3384730dcf1f90c42f8eedc3588 100644 (file)
@@ -93,7 +93,7 @@ static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg)
 
 #endif
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 
 extern void usb_autosuspend_device(struct usb_device *udev);
 extern int usb_autoresume_device(struct usb_device *udev);
index 170b9399e09f34b42ec798b8e02985c5b0f71190..a573d5ff9adcf213dad7014cc24e434df22a3346 100644 (file)
@@ -292,17 +292,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
                }
        }
 
-#ifdef CONFIG_USB_SUSPEND
-       /* REVISIT: the controller works fine for wakeup iff the root hub
-        * itself is "globally" suspended, but usbcore currently doesn't
-        * understand such things.
-        *
-        * System suspend currently expects to be able to suspend the entire
-        * device tree, device-at-a-time.  If we failed selective suspend
-        * reports, system suspend would fail; so the root hub code must claim
-        * success.  That's lying to usbcore, and it matters for runtime
-        * PM scenarios with selective suspend and remote wakeup...
-        */
+#ifdef CONFIG_PM_RUNTIME
        if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev))
                ehci_warn(ehci, "selective suspend/wakeup unavailable\n");
 #endif
index db09dae7b557a18063d424a3ffc58c1edb8ccca8..60ff4220e8b4fbe771857f5b1316e02663eccf68 100644 (file)
@@ -580,14 +580,8 @@ static int ohci_start_port_reset (struct usb_hcd *hcd, unsigned port)
 
 /* See usb 7.1.7.5:  root hubs must issue at least 50 msec reset signaling,
  * not necessarily continuous ... to guard against resume signaling.
- * The short timeout is safe for non-root hubs, and is backward-compatible
- * with earlier Linux hosts.
  */
-#ifdef CONFIG_USB_SUSPEND
 #define        PORT_RESET_MSEC         50
-#else
-#define        PORT_RESET_MSEC         10
-#endif
 
 /* this timer value might be vendor-specific ... */
 #define        PORT_RESET_HW_MSEC      10
index d62f0404baaa636d82e3b409edf4581c7e92ab03..15ed7e8d887f6897781715ca42a0b12018e0e99a 100644 (file)
@@ -1755,7 +1755,7 @@ sl811h_probe(struct platform_device *dev)
 
 /* for this device there's no useful distinction between the controller
  * and its root hub, except that the root hub only gets direct PM calls
- * when CONFIG_USB_SUSPEND is enabled.
+ * when CONFIG_PM_RUNTIME is enabled.
  */
 
 static int
index 5efdffe3236572e4f7b3141a6a8ab5f4fb95d721..5c124bf5d01869c727543b34240deace3d27d1cd 100644 (file)
@@ -3141,10 +3141,11 @@ static int u132_probe(struct platform_device *pdev)
 
 
 #ifdef CONFIG_PM
-/* for this device there's no useful distinction between the controller
-* and its root hub, except that the root hub only gets direct PM calls
-* when CONFIG_USB_SUSPEND is enabled.
-*/
+/*
+ * for this device there's no useful distinction between the controller
+ * and its root hub, except that the root hub only gets direct PM calls
+ * when CONFIG_PM_RUNTIME is enabled.
+ */
 static int u132_suspend(struct platform_device *pdev, pm_message_t state)
 {
        struct usb_hcd *hcd = platform_get_drvdata(pdev);
index 68914429482f30ff4afed47180aae563d07c5784..187a3ec1069ace87d28b888823e4c4e38053f80b 100644 (file)
@@ -1075,7 +1075,7 @@ int xhci_bus_suspend(struct usb_hcd *hcd)
                        set_bit(port_index, &bus_state->bus_suspended);
                }
                /* USB core sets remote wake mask for USB 3.0 hubs,
-                * including the USB 3.0 roothub, but only if CONFIG_USB_SUSPEND
+                * including the USB 3.0 roothub, but only if CONFIG_PM_RUNTIME
                 * is enabled, so also enable remote wake here.
                 */
                if (hcd->self.root_hub->do_remote_wakeup) {
index 53b8f89a0b1c7e6199c95672c85d3d27fb3e0b90..5156b720a53a5f5d63a66b0ce7b287eff3deaada 100644 (file)
@@ -3801,7 +3801,7 @@ int xhci_find_raw_port_number(struct usb_hcd *hcd, int port1)
        return raw_port;
 }
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 
 /* BESL to HIRD Encoding array for USB2 LPM */
 static int xhci_besl_encoding[16] = {125, 150, 200, 300, 400, 500, 1000, 2000,
@@ -4051,7 +4051,7 @@ int xhci_update_device(struct usb_hcd *hcd, struct usb_device *udev)
        return 0;
 }
 
-#endif /* CONFIG_USB_SUSPEND */
+#endif /* CONFIG_PM_RUNTIME */
 
 /*---------------------- USB 3.0 Link PM functions ------------------------*/
 
index 8d4bc173d66a56827e3d3b3a99752d5126b1d76c..a0bee5a28d1a578a27829edd231968e1ff11ce1d 100644 (file)
@@ -617,7 +617,7 @@ static inline bool usb_acpi_power_manageable(struct usb_device *hdev, int index)
 #endif
 
 /* USB autosuspend and autoresume */
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 extern void usb_enable_autosuspend(struct usb_device *udev);
 extern void usb_disable_autosuspend(struct usb_device *udev);
 
index 59694b5e5e906821a873d52a1a33b9c5d67af5d4..f5f5c7dfda90ebe2656176c058672b75854c3176 100644 (file)
@@ -84,7 +84,7 @@ struct usb_hcd {
 
        struct timer_list       rh_timer;       /* drives root-hub polling */
        struct urb              *status_urb;    /* the current status urb */
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
        struct work_struct      wakeup_work;    /* for remote wakeup */
 #endif
 
@@ -593,14 +593,14 @@ extern int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg);
 extern int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg);
 #endif /* CONFIG_PM */
 
-#ifdef CONFIG_USB_SUSPEND
+#ifdef CONFIG_PM_RUNTIME
 extern void usb_hcd_resume_root_hub(struct usb_hcd *hcd);
 #else
 static inline void usb_hcd_resume_root_hub(struct usb_hcd *hcd)
 {
        return;
 }
-#endif /* CONFIG_USB_SUSPEND */
+#endif /* CONFIG_PM_RUNTIME */
 
 /*-------------------------------------------------------------------------*/