Commit 9e18c821 authored by Alan Stern's avatar Alan Stern Committed by Greg Kroah-Hartman

USB: use PM core routines to enable/disable autosuspend

This patch (as1366) replaces the private routines
usb_enable_autosuspend() and usb_disable_autosuspend() with calls to
the standard pm_runtime_allow() and pm_runtime_forbid() functions in
the runtime PM framework.  They do the same thing.
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 7aba8d01
...@@ -1356,13 +1356,9 @@ int usb_resume(struct device *dev, pm_message_t msg) ...@@ -1356,13 +1356,9 @@ int usb_resume(struct device *dev, pm_message_t msg)
* *
* The caller must hold @udev's device lock. * The caller must hold @udev's device lock.
*/ */
int usb_enable_autosuspend(struct usb_device *udev) void usb_enable_autosuspend(struct usb_device *udev)
{ {
if (udev->autosuspend_disabled) { pm_runtime_allow(&udev->dev);
udev->autosuspend_disabled = 0;
usb_autosuspend_device(udev);
}
return 0;
} }
EXPORT_SYMBOL_GPL(usb_enable_autosuspend); EXPORT_SYMBOL_GPL(usb_enable_autosuspend);
...@@ -1375,16 +1371,9 @@ EXPORT_SYMBOL_GPL(usb_enable_autosuspend); ...@@ -1375,16 +1371,9 @@ EXPORT_SYMBOL_GPL(usb_enable_autosuspend);
* *
* The caller must hold @udev's device lock. * The caller must hold @udev's device lock.
*/ */
int usb_disable_autosuspend(struct usb_device *udev) void usb_disable_autosuspend(struct usb_device *udev)
{ {
int rc = 0; pm_runtime_forbid(&udev->dev);
if (!udev->autosuspend_disabled) {
rc = usb_autoresume_device(udev);
if (rc == 0)
udev->autosuspend_disabled = 1;
}
return rc;
} }
EXPORT_SYMBOL_GPL(usb_disable_autosuspend); EXPORT_SYMBOL_GPL(usb_disable_autosuspend);
...@@ -1528,7 +1517,7 @@ void usb_autopm_put_interface_async(struct usb_interface *intf) ...@@ -1528,7 +1517,7 @@ void usb_autopm_put_interface_async(struct usb_interface *intf)
atomic_dec(&intf->pm_usage_cnt); atomic_dec(&intf->pm_usage_cnt);
pm_runtime_put_noidle(&intf->dev); pm_runtime_put_noidle(&intf->dev);
if (!udev->autosuspend_disabled) { if (udev->dev.power.runtime_auto) {
/* Optimization: Don't schedule a delayed autosuspend if /* Optimization: Don't schedule a delayed autosuspend if
* the timer is already running and the expiration time * the timer is already running and the expiration time
* wouldn't change. * wouldn't change.
......
...@@ -389,7 +389,7 @@ show_level(struct device *dev, struct device_attribute *attr, char *buf) ...@@ -389,7 +389,7 @@ show_level(struct device *dev, struct device_attribute *attr, char *buf)
struct usb_device *udev = to_usb_device(dev); struct usb_device *udev = to_usb_device(dev);
const char *p = auto_string; const char *p = auto_string;
if (udev->state != USB_STATE_SUSPENDED && udev->autosuspend_disabled) if (udev->state != USB_STATE_SUSPENDED && !udev->dev.power.runtime_auto)
p = on_string; p = on_string;
return sprintf(buf, "%s\n", p); return sprintf(buf, "%s\n", p);
} }
...@@ -401,7 +401,7 @@ set_level(struct device *dev, struct device_attribute *attr, ...@@ -401,7 +401,7 @@ set_level(struct device *dev, struct device_attribute *attr,
struct usb_device *udev = to_usb_device(dev); struct usb_device *udev = to_usb_device(dev);
int len = count; int len = count;
char *cp; char *cp;
int rc; int rc = count;
cp = memchr(buf, '\n', count); cp = memchr(buf, '\n', count);
if (cp) if (cp)
...@@ -411,17 +411,17 @@ set_level(struct device *dev, struct device_attribute *attr, ...@@ -411,17 +411,17 @@ set_level(struct device *dev, struct device_attribute *attr,
if (len == sizeof on_string - 1 && if (len == sizeof on_string - 1 &&
strncmp(buf, on_string, len) == 0) strncmp(buf, on_string, len) == 0)
rc = usb_disable_autosuspend(udev); usb_disable_autosuspend(udev);
else if (len == sizeof auto_string - 1 && else if (len == sizeof auto_string - 1 &&
strncmp(buf, auto_string, len) == 0) strncmp(buf, auto_string, len) == 0)
rc = usb_enable_autosuspend(udev); usb_enable_autosuspend(udev);
else else
rc = -EINVAL; rc = -EINVAL;
usb_unlock_device(udev); usb_unlock_device(udev);
return (rc < 0 ? rc : count); return rc;
} }
static DEVICE_ATTR(level, S_IRUGO | S_IWUSR, show_level, set_level); static DEVICE_ATTR(level, S_IRUGO | S_IWUSR, show_level, set_level);
......
...@@ -425,7 +425,6 @@ struct usb_tt; ...@@ -425,7 +425,6 @@ struct usb_tt;
* @connect_time: time device was first connected * @connect_time: time device was first connected
* @do_remote_wakeup: remote wakeup should be enabled * @do_remote_wakeup: remote wakeup should be enabled
* @reset_resume: needs reset instead of resume * @reset_resume: needs reset instead of resume
* @autosuspend_disabled: autosuspend disabled by the user
* @wusb_dev: if this is a Wireless USB device, link to the WUSB * @wusb_dev: if this is a Wireless USB device, link to the WUSB
* specific data for the device. * specific data for the device.
* @slot_id: Slot ID assigned by xHCI * @slot_id: Slot ID assigned by xHCI
...@@ -501,7 +500,6 @@ struct usb_device { ...@@ -501,7 +500,6 @@ struct usb_device {
unsigned do_remote_wakeup:1; unsigned do_remote_wakeup:1;
unsigned reset_resume:1; unsigned reset_resume:1;
unsigned autosuspend_disabled:1;
#endif #endif
struct wusb_dev *wusb_dev; struct wusb_dev *wusb_dev;
int slot_id; int slot_id;
...@@ -526,8 +524,8 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); ...@@ -526,8 +524,8 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id);
/* USB autosuspend and autoresume */ /* USB autosuspend and autoresume */
#ifdef CONFIG_USB_SUSPEND #ifdef CONFIG_USB_SUSPEND
extern int usb_enable_autosuspend(struct usb_device *udev); extern void usb_enable_autosuspend(struct usb_device *udev);
extern int usb_disable_autosuspend(struct usb_device *udev); extern void usb_disable_autosuspend(struct usb_device *udev);
extern int usb_autopm_get_interface(struct usb_interface *intf); extern int usb_autopm_get_interface(struct usb_interface *intf);
extern void usb_autopm_put_interface(struct usb_interface *intf); extern void usb_autopm_put_interface(struct usb_interface *intf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment