Skip to content

Commit

Permalink
USB / PM: Drop CONFIG_PM_RUNTIME from the USB core
Browse files Browse the repository at this point in the history
After commit b2b49cc (PM: Kconfig: Set PM_RUNTIME if PM_SLEEP is
selected) PM_RUNTIME is always set if PM is set, so quite a few
depend on CONFIG_PM (or even dropped in some cases).

Replace CONFIG_PM_RUNTIME with CONFIG_PM in the USB core code
and documentation.

Signed-off-by: Rafael J. Wysocki <[email protected]>
Acked-by: Alan Stern <[email protected]>
Acked-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
rafaeljw committed Dec 3, 2014
1 parent 6ed23b8 commit ceb6c9c
Show file tree
Hide file tree
Showing 19 changed files with 69 additions and 112 deletions.
14 changes: 6 additions & 8 deletions Documentation/ABI/stable/sysfs-bus-usb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,9 @@ Date: January 2008
KernelVersion: 2.6.25
Contact: Sarah Sharp <[email protected]>
Description:
If CONFIG_PM_RUNTIME is enabled then this file
is present. When read, it returns the total time (in msec)
that the USB device has been connected to the machine. This
file is read-only.
If CONFIG_PM is enabled, then this file is present. When read,
it returns the total time (in msec) that the USB device has been
connected to the machine. This file is read-only.
Users:
PowerTOP <[email protected]>
https://01.org/powertop/
Expand All @@ -45,10 +44,9 @@ Date: January 2008
KernelVersion: 2.6.25
Contact: Sarah Sharp <[email protected]>
Description:
If CONFIG_PM_RUNTIME is enabled then this file
is present. When read, it returns the total time (in msec)
that the USB device has been active, i.e. not in a suspended
state. This file is read-only.
If CONFIG_PM is enabled, then this file is present. When read,
it returns the total time (in msec) that the USB device has been
active, i.e. not in a suspended state. This file is read-only.

Tools can use this file and the connected_duration file to
compute the percentage of time that a device has been active.
Expand Down
19 changes: 9 additions & 10 deletions Documentation/ABI/testing/sysfs-bus-usb
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,15 @@ What: /sys/bus/usb/devices/.../power/usb2_hardware_lpm
Date: September 2011
Contact: Andiry Xu <[email protected]>
Description:
If CONFIG_PM_RUNTIME is set and a USB 2.0 lpm-capable device
is plugged in to a xHCI host which support link PM, it will
perform a LPM test; if the test is passed and host supports
USB2 hardware LPM (xHCI 1.0 feature), USB2 hardware LPM will
be enabled for the device and the USB device directory will
contain a file named power/usb2_hardware_lpm. The file holds
a string value (enable or disable) indicating whether or not
USB2 hardware LPM is enabled for the device. Developer can
write y/Y/1 or n/N/0 to the file to enable/disable the
feature.
If CONFIG_PM is set and a USB 2.0 lpm-capable device is plugged
in to a xHCI host which support link PM, it will perform a LPM
test; if the test is passed and host supports USB2 hardware LPM
(xHCI 1.0 feature), USB2 hardware LPM will be enabled for the
device and the USB device directory will contain a file named
power/usb2_hardware_lpm. The file holds a string value (enable
or disable) indicating whether or not USB2 hardware LPM is
enabled for the device. Developer can write y/Y/1 or n/N/0 to
the file to enable/disable the feature.

What: /sys/bus/usb/devices/.../removable
Date: February 2012
Expand Down
17 changes: 9 additions & 8 deletions Documentation/usb/power-management.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,15 @@ dynamic PM is implemented in the USB subsystem, although system PM is
covered to some extent (see Documentation/power/*.txt for more
information about system PM).

Note: Dynamic PM support for USB is present only if the kernel was
built with CONFIG_USB_SUSPEND enabled (which depends on
CONFIG_PM_RUNTIME). System PM support is present only if the kernel
was built with CONFIG_SUSPEND or CONFIG_HIBERNATION enabled.

(Starting with the 3.10 kernel release, dynamic PM support for USB is
present whenever the kernel was built with CONFIG_PM_RUNTIME enabled.
The CONFIG_USB_SUSPEND option has been eliminated.)
System PM support is present only if the kernel was built with CONFIG_SUSPEND
or CONFIG_HIBERNATION enabled. Dynamic PM support for USB is present whenever
the kernel was built with CONFIG_PM enabled.

[Historically, dynamic PM support for USB was present only if the
kernel had been built with CONFIG_USB_SUSPEND enabled (which depended on
CONFIG_PM_RUNTIME). Starting with the 3.10 kernel release, dynamic PM support
for USB was present whenever the kernel was built with CONFIG_PM_RUNTIME
enabled. The CONFIG_USB_SUSPEND option had been eliminated.]


What is Remote Wakeup?
Expand Down
6 changes: 1 addition & 5 deletions drivers/usb/core/driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -1493,10 +1493,6 @@ int usb_resume(struct device *dev, pm_message_t msg)
return status;
}

#endif /* CONFIG_PM */

#ifdef CONFIG_PM_RUNTIME

/**
* usb_enable_autosuspend - allow a USB device to be autosuspended
* @udev: the USB device which may be autosuspended
Expand Down Expand Up @@ -1876,7 +1872,7 @@ int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
return ret;
}

#endif /* CONFIG_PM_RUNTIME */
#endif /* CONFIG_PM */

struct bus_type usb_bus_type = {
.name = "usb",
Expand Down
11 changes: 0 additions & 11 deletions drivers/usb/core/hcd-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,6 @@ static int check_root_hub_suspended(struct device *dev)
return 0;
}

#if defined(CONFIG_PM_SLEEP) || defined(CONFIG_PM_RUNTIME)
static int suspend_common(struct device *dev, bool do_wakeup)
{
struct pci_dev *pci_dev = to_pci_dev(dev);
Expand Down Expand Up @@ -528,7 +527,6 @@ static int resume_common(struct device *dev, int event)
}
return retval;
}
#endif /* SLEEP || RUNTIME */

#ifdef CONFIG_PM_SLEEP

Expand Down Expand Up @@ -607,8 +605,6 @@ static int hcd_pci_restore(struct device *dev)

#endif /* CONFIG_PM_SLEEP */

#ifdef CONFIG_PM_RUNTIME

static int hcd_pci_runtime_suspend(struct device *dev)
{
int retval;
Expand All @@ -630,13 +626,6 @@ static int hcd_pci_runtime_resume(struct device *dev)
return retval;
}

#else

#define hcd_pci_runtime_suspend NULL
#define hcd_pci_runtime_resume NULL

#endif /* CONFIG_PM_RUNTIME */

const struct dev_pm_ops usb_hcd_pci_pm_ops = {
.suspend = hcd_pci_suspend,
.suspend_noirq = hcd_pci_suspend_noirq,
Expand Down
12 changes: 4 additions & 8 deletions drivers/usb/core/hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -2258,10 +2258,6 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
return status;
}

#endif /* CONFIG_PM */

#ifdef CONFIG_PM_RUNTIME

/* Workqueue routine for root-hub remote wakeup */
static void hcd_resume_work(struct work_struct *work)
{
Expand Down Expand Up @@ -2293,7 +2289,7 @@ void usb_hcd_resume_root_hub (struct usb_hcd *hcd)
}
EXPORT_SYMBOL_GPL(usb_hcd_resume_root_hub);

#endif /* CONFIG_PM_RUNTIME */
#endif /* CONFIG_PM */

/*-------------------------------------------------------------------------*/

Expand Down Expand Up @@ -2476,7 +2472,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_PM_RUNTIME
#ifdef CONFIG_PM
INIT_WORK(&hcd->wakeup_work, hcd_resume_work);
#endif

Expand Down Expand Up @@ -2790,7 +2786,7 @@ int usb_add_hcd(struct usb_hcd *hcd,
hcd->rh_registered = 0;
spin_unlock_irq(&hcd_root_hub_lock);

#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM
cancel_work_sync(&hcd->wakeup_work);
#endif
mutex_lock(&usb_bus_list_lock);
Expand Down Expand Up @@ -2858,7 +2854,7 @@ void usb_remove_hcd(struct usb_hcd *hcd)
hcd->rh_registered = 0;
spin_unlock_irq (&hcd_root_hub_lock);

#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM
cancel_work_sync(&hcd->wakeup_work);
#endif

Expand Down
6 changes: 3 additions & 3 deletions drivers/usb/core/hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1737,7 +1737,7 @@ static int hub_probe(struct usb_interface *intf, const struct usb_device_id *id)
* - If user has indicated to prevent autosuspend by passing
* usbcore.autosuspend = -1 then keep autosuspend disabled.
*/
#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM
if (hdev->dev.power.autosuspend_delay >= 0)
pm_runtime_set_autosuspend_delay(&hdev->dev, 0);
#endif
Expand Down Expand Up @@ -3449,7 +3449,7 @@ int usb_port_resume(struct usb_device *udev, pm_message_t msg)
return status;
}

#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM

int usb_remote_wakeup(struct usb_device *udev)
{
Expand Down Expand Up @@ -4856,7 +4856,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
udev->state != USB_STATE_NOTATTACHED) {
if (portstatus & USB_PORT_STAT_ENABLE) {
status = 0; /* Nothing to do */
#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM
} else if (udev->state == USB_STATE_SUSPENDED &&
udev->persist_enabled) {
/* For a suspended device, treat this as a
Expand Down
4 changes: 2 additions & 2 deletions drivers/usb/core/port.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ static void usb_port_device_release(struct device *dev)
kfree(port_dev);
}

#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM
static int usb_port_runtime_resume(struct device *dev)
{
struct usb_port *port_dev = to_usb_port(dev);
Expand Down Expand Up @@ -171,7 +171,7 @@ static int usb_port_runtime_suspend(struct device *dev)
#endif

static const struct dev_pm_ops usb_port_pm_ops = {
#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM
.runtime_suspend = usb_port_runtime_suspend,
.runtime_resume = usb_port_runtime_resume,
#endif
Expand Down
13 changes: 4 additions & 9 deletions drivers/usb/core/sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,6 @@ static void remove_persist_attributes(struct device *dev)
&dev_attr_persist.attr,
power_group_name);
}
#else

#define add_persist_attributes(dev) 0
#define remove_persist_attributes(dev) do {} while (0)

#endif /* CONFIG_PM */

#ifdef CONFIG_PM_RUNTIME

static ssize_t connected_duration_show(struct device *dev,
struct device_attribute *attr, char *buf)
Expand Down Expand Up @@ -585,10 +577,13 @@ static void remove_power_attributes(struct device *dev)

#else

#define add_persist_attributes(dev) 0
#define remove_persist_attributes(dev) do {} while (0)

#define add_power_attributes(dev) 0
#define remove_power_attributes(dev) do {} while (0)

#endif /* CONFIG_PM_RUNTIME */
#endif /* CONFIG_PM */


/* Descriptor fields */
Expand Down
4 changes: 1 addition & 3 deletions drivers/usb/core/usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const char *usbcore_name = "usbcore";

static bool nousb; /* Disable USB when built into kernel image */

#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM
static int usb_autosuspend_delay = 2; /* Default delay value,
* in seconds */
module_param_named(autosuspend, usb_autosuspend_delay, int, 0644);
Expand Down Expand Up @@ -348,11 +348,9 @@ static const struct dev_pm_ops usb_device_pm_ops = {
.thaw = usb_dev_thaw,
.poweroff = usb_dev_poweroff,
.restore = usb_dev_restore,
#ifdef CONFIG_PM_RUNTIME
.runtime_suspend = usb_runtime_suspend,
.runtime_resume = usb_runtime_resume,
.runtime_idle = usb_runtime_idle,
#endif
};

#endif /* CONFIG_PM */
Expand Down
23 changes: 9 additions & 14 deletions drivers/usb/core/usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ extern int usb_resume_complete(struct device *dev);
extern int usb_port_suspend(struct usb_device *dev, pm_message_t msg);
extern int usb_port_resume(struct usb_device *dev, pm_message_t msg);

extern void usb_autosuspend_device(struct usb_device *udev);
extern int usb_autoresume_device(struct usb_device *udev);
extern int usb_remote_wakeup(struct usb_device *dev);
extern int usb_runtime_suspend(struct device *dev);
extern int usb_runtime_resume(struct device *dev);
extern int usb_runtime_idle(struct device *dev);
extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable);

#else

static inline int usb_port_suspend(struct usb_device *udev, pm_message_t msg)
Expand All @@ -87,20 +95,6 @@ static inline int usb_port_resume(struct usb_device *udev, pm_message_t msg)
return 0;
}

#endif

#ifdef CONFIG_PM_RUNTIME

extern void usb_autosuspend_device(struct usb_device *udev);
extern int usb_autoresume_device(struct usb_device *udev);
extern int usb_remote_wakeup(struct usb_device *dev);
extern int usb_runtime_suspend(struct device *dev);
extern int usb_runtime_resume(struct device *dev);
extern int usb_runtime_idle(struct device *dev);
extern int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable);

#else

#define usb_autosuspend_device(udev) do {} while (0)
static inline int usb_autoresume_device(struct usb_device *udev)
{
Expand All @@ -111,6 +105,7 @@ static inline int usb_set_usb2_hardware_lpm(struct usb_device *udev, int enable)
{
return 0;
}

#endif

extern struct bus_type usb_bus_type;
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/ehci-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ static int ehci_pci_setup(struct usb_hcd *hcd)
}
}

#ifdef CONFIG_PM_RUNTIME
#ifdef CONFIG_PM
if (ehci->no_selective_suspend && device_can_wakeup(&pdev->dev))
ehci_warn(ehci, "selective suspend/wakeup unavailable\n");
#endif
Expand Down
5 changes: 2 additions & 3 deletions drivers/usb/host/sl811-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* and usb-storage.
*
* TODO:
* - usb suspend/resume triggered by sl811 (with PM_RUNTIME)
* - usb suspend/resume triggered by sl811
* - various issues noted in the code
* - performance work; use both register banks; ...
* - use urb->iso_frame_desc[] with ISO transfers
Expand Down Expand Up @@ -1752,8 +1752,7 @@ sl811h_probe(struct platform_device *dev)
#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_PM_RUNTIME is enabled.
* and its root hub.
*/

static int
Expand Down
3 changes: 1 addition & 2 deletions drivers/usb/host/u132-hcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3144,8 +3144,7 @@ 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_PM_RUNTIME is enabled.
* and its root hub.
*/
static int u132_suspend(struct platform_device *pdev, pm_message_t state)
{
Expand Down
2 changes: 1 addition & 1 deletion drivers/usb/host/xhci-hub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1146,7 +1146,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_PM_RUNTIME
* including the USB 3.0 roothub, but only if CONFIG_PM
* is enabled, so also enable remote wake here.
*/
if (hcd->self.root_hub->do_remote_wakeup
Expand Down
Loading

0 comments on commit ceb6c9c

Please sign in to comment.