diff options
author | Alan Stern <stern@rowland.harvard.edu> | 2010-04-02 13:22:09 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-20 16:21:37 -0400 |
commit | 9e18c821659d836bd63f88df3c19729327728496 (patch) | |
tree | 4148e58d0e03aecfe0dbeedd175bc960006570a9 | |
parent | 7aba8d014341341590ecb64050b7a026642a62eb (diff) |
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: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/driver.c | 21 | ||||
-rw-r--r-- | drivers/usb/core/sysfs.c | 10 | ||||
-rw-r--r-- | include/linux/usb.h | 6 |
3 files changed, 12 insertions, 25 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 271e857be0fa..207146743ea7 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -1356,13 +1356,9 @@ int usb_resume(struct device *dev, pm_message_t msg) | |||
1356 | * | 1356 | * |
1357 | * The caller must hold @udev's device lock. | 1357 | * The caller must hold @udev's device lock. |
1358 | */ | 1358 | */ |
1359 | int usb_enable_autosuspend(struct usb_device *udev) | 1359 | void usb_enable_autosuspend(struct usb_device *udev) |
1360 | { | 1360 | { |
1361 | if (udev->autosuspend_disabled) { | 1361 | pm_runtime_allow(&udev->dev); |
1362 | udev->autosuspend_disabled = 0; | ||
1363 | usb_autosuspend_device(udev); | ||
1364 | } | ||
1365 | return 0; | ||
1366 | } | 1362 | } |
1367 | EXPORT_SYMBOL_GPL(usb_enable_autosuspend); | 1363 | EXPORT_SYMBOL_GPL(usb_enable_autosuspend); |
1368 | 1364 | ||
@@ -1375,16 +1371,9 @@ EXPORT_SYMBOL_GPL(usb_enable_autosuspend); | |||
1375 | * | 1371 | * |
1376 | * The caller must hold @udev's device lock. | 1372 | * The caller must hold @udev's device lock. |
1377 | */ | 1373 | */ |
1378 | int usb_disable_autosuspend(struct usb_device *udev) | 1374 | void usb_disable_autosuspend(struct usb_device *udev) |
1379 | { | 1375 | { |
1380 | int rc = 0; | 1376 | pm_runtime_forbid(&udev->dev); |
1381 | |||
1382 | if (!udev->autosuspend_disabled) { | ||
1383 | rc = usb_autoresume_device(udev); | ||
1384 | if (rc == 0) | ||
1385 | udev->autosuspend_disabled = 1; | ||
1386 | } | ||
1387 | return rc; | ||
1388 | } | 1377 | } |
1389 | EXPORT_SYMBOL_GPL(usb_disable_autosuspend); | 1378 | EXPORT_SYMBOL_GPL(usb_disable_autosuspend); |
1390 | 1379 | ||
@@ -1528,7 +1517,7 @@ void usb_autopm_put_interface_async(struct usb_interface *intf) | |||
1528 | atomic_dec(&intf->pm_usage_cnt); | 1517 | atomic_dec(&intf->pm_usage_cnt); |
1529 | pm_runtime_put_noidle(&intf->dev); | 1518 | pm_runtime_put_noidle(&intf->dev); |
1530 | 1519 | ||
1531 | if (!udev->autosuspend_disabled) { | 1520 | if (udev->dev.power.runtime_auto) { |
1532 | /* Optimization: Don't schedule a delayed autosuspend if | 1521 | /* Optimization: Don't schedule a delayed autosuspend if |
1533 | * the timer is already running and the expiration time | 1522 | * the timer is already running and the expiration time |
1534 | * wouldn't change. | 1523 | * wouldn't change. |
diff --git a/drivers/usb/core/sysfs.c b/drivers/usb/core/sysfs.c index 43c002e3a9aa..b65c1eaf3aba 100644 --- a/drivers/usb/core/sysfs.c +++ b/drivers/usb/core/sysfs.c | |||
@@ -389,7 +389,7 @@ show_level(struct device *dev, struct device_attribute *attr, char *buf) | |||
389 | struct usb_device *udev = to_usb_device(dev); | 389 | struct usb_device *udev = to_usb_device(dev); |
390 | const char *p = auto_string; | 390 | const char *p = auto_string; |
391 | 391 | ||
392 | if (udev->state != USB_STATE_SUSPENDED && udev->autosuspend_disabled) | 392 | if (udev->state != USB_STATE_SUSPENDED && !udev->dev.power.runtime_auto) |
393 | p = on_string; | 393 | p = on_string; |
394 | return sprintf(buf, "%s\n", p); | 394 | return sprintf(buf, "%s\n", p); |
395 | } | 395 | } |
@@ -401,7 +401,7 @@ set_level(struct device *dev, struct device_attribute *attr, | |||
401 | struct usb_device *udev = to_usb_device(dev); | 401 | struct usb_device *udev = to_usb_device(dev); |
402 | int len = count; | 402 | int len = count; |
403 | char *cp; | 403 | char *cp; |
404 | int rc; | 404 | int rc = count; |
405 | 405 | ||
406 | cp = memchr(buf, '\n', count); | 406 | cp = memchr(buf, '\n', count); |
407 | if (cp) | 407 | if (cp) |
@@ -411,17 +411,17 @@ set_level(struct device *dev, struct device_attribute *attr, | |||
411 | 411 | ||
412 | if (len == sizeof on_string - 1 && | 412 | if (len == sizeof on_string - 1 && |
413 | strncmp(buf, on_string, len) == 0) | 413 | strncmp(buf, on_string, len) == 0) |
414 | rc = usb_disable_autosuspend(udev); | 414 | usb_disable_autosuspend(udev); |
415 | 415 | ||
416 | else if (len == sizeof auto_string - 1 && | 416 | else if (len == sizeof auto_string - 1 && |
417 | strncmp(buf, auto_string, len) == 0) | 417 | strncmp(buf, auto_string, len) == 0) |
418 | rc = usb_enable_autosuspend(udev); | 418 | usb_enable_autosuspend(udev); |
419 | 419 | ||
420 | else | 420 | else |
421 | rc = -EINVAL; | 421 | rc = -EINVAL; |
422 | 422 | ||
423 | usb_unlock_device(udev); | 423 | usb_unlock_device(udev); |
424 | return (rc < 0 ? rc : count); | 424 | return rc; |
425 | } | 425 | } |
426 | 426 | ||
427 | static DEVICE_ATTR(level, S_IRUGO | S_IWUSR, show_level, set_level); | 427 | static DEVICE_ATTR(level, S_IRUGO | S_IWUSR, show_level, set_level); |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 99833029e5a8..e32a849f81ce 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -425,7 +425,6 @@ struct usb_tt; | |||
425 | * @connect_time: time device was first connected | 425 | * @connect_time: time device was first connected |
426 | * @do_remote_wakeup: remote wakeup should be enabled | 426 | * @do_remote_wakeup: remote wakeup should be enabled |
427 | * @reset_resume: needs reset instead of resume | 427 | * @reset_resume: needs reset instead of resume |
428 | * @autosuspend_disabled: autosuspend disabled by the user | ||
429 | * @wusb_dev: if this is a Wireless USB device, link to the WUSB | 428 | * @wusb_dev: if this is a Wireless USB device, link to the WUSB |
430 | * specific data for the device. | 429 | * specific data for the device. |
431 | * @slot_id: Slot ID assigned by xHCI | 430 | * @slot_id: Slot ID assigned by xHCI |
@@ -501,7 +500,6 @@ struct usb_device { | |||
501 | 500 | ||
502 | unsigned do_remote_wakeup:1; | 501 | unsigned do_remote_wakeup:1; |
503 | unsigned reset_resume:1; | 502 | unsigned reset_resume:1; |
504 | unsigned autosuspend_disabled:1; | ||
505 | #endif | 503 | #endif |
506 | struct wusb_dev *wusb_dev; | 504 | struct wusb_dev *wusb_dev; |
507 | int slot_id; | 505 | int slot_id; |
@@ -526,8 +524,8 @@ extern struct usb_device *usb_find_device(u16 vendor_id, u16 product_id); | |||
526 | 524 | ||
527 | /* USB autosuspend and autoresume */ | 525 | /* USB autosuspend and autoresume */ |
528 | #ifdef CONFIG_USB_SUSPEND | 526 | #ifdef CONFIG_USB_SUSPEND |
529 | extern int usb_enable_autosuspend(struct usb_device *udev); | 527 | extern void usb_enable_autosuspend(struct usb_device *udev); |
530 | extern int usb_disable_autosuspend(struct usb_device *udev); | 528 | extern void usb_disable_autosuspend(struct usb_device *udev); |
531 | 529 | ||
532 | extern int usb_autopm_get_interface(struct usb_interface *intf); | 530 | extern int usb_autopm_get_interface(struct usb_interface *intf); |
533 | extern void usb_autopm_put_interface(struct usb_interface *intf); | 531 | extern void usb_autopm_put_interface(struct usb_interface *intf); |