diff options
author | Ming Lei <tom.leiming@gmail.com> | 2010-11-15 15:57:30 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-11-16 17:02:54 -0500 |
commit | 6ddf27cdbc218a412d7e993fdc08e30eec2042ce (patch) | |
tree | 393232ac1a8123961b62cb72cfc4b0bc617b333c | |
parent | 045cac6b3b067a9286dabfb789f67ae4f433f88b (diff) |
USB: make usb_mark_last_busy use pm_runtime_mark_last_busy
Since the runtime-PM core already defines a .last_busy field in
device.power, this patch uses it to replace the .last_busy field
defined in usb_device and uses pm_runtime_mark_last_busy to implement
usb_mark_last_busy.
Signed-off-by: Ming Lei <tom.leiming@gmail.com>
Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r-- | drivers/usb/core/driver.c | 23 | ||||
-rw-r--r-- | drivers/usb/core/hcd-pci.c | 1 | ||||
-rw-r--r-- | drivers/usb/core/hcd.c | 1 | ||||
-rw-r--r-- | drivers/usb/core/hub.c | 1 | ||||
-rw-r--r-- | drivers/usb/core/message.c | 1 | ||||
-rw-r--r-- | include/linux/usb.h | 5 |
6 files changed, 13 insertions, 19 deletions
diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index eda2d2c2545..0a63e968c68 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <linux/usb.h> | 27 | #include <linux/usb.h> |
28 | #include <linux/usb/quirks.h> | 28 | #include <linux/usb/quirks.h> |
29 | #include <linux/usb/hcd.h> | 29 | #include <linux/usb/hcd.h> |
30 | #include <linux/pm_runtime.h> | ||
31 | 30 | ||
32 | #include "usb.h" | 31 | #include "usb.h" |
33 | 32 | ||
@@ -1329,7 +1328,7 @@ int usb_resume(struct device *dev, pm_message_t msg) | |||
1329 | pm_runtime_disable(dev); | 1328 | pm_runtime_disable(dev); |
1330 | pm_runtime_set_active(dev); | 1329 | pm_runtime_set_active(dev); |
1331 | pm_runtime_enable(dev); | 1330 | pm_runtime_enable(dev); |
1332 | udev->last_busy = jiffies; | 1331 | usb_mark_last_busy(udev); |
1333 | do_unbind_rebind(udev, DO_REBIND); | 1332 | do_unbind_rebind(udev, DO_REBIND); |
1334 | } | 1333 | } |
1335 | } | 1334 | } |
@@ -1397,7 +1396,7 @@ void usb_autosuspend_device(struct usb_device *udev) | |||
1397 | { | 1396 | { |
1398 | int status; | 1397 | int status; |
1399 | 1398 | ||
1400 | udev->last_busy = jiffies; | 1399 | usb_mark_last_busy(udev); |
1401 | status = pm_runtime_put_sync(&udev->dev); | 1400 | status = pm_runtime_put_sync(&udev->dev); |
1402 | dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", | 1401 | dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n", |
1403 | __func__, atomic_read(&udev->dev.power.usage_count), | 1402 | __func__, atomic_read(&udev->dev.power.usage_count), |
@@ -1482,7 +1481,7 @@ void usb_autopm_put_interface(struct usb_interface *intf) | |||
1482 | struct usb_device *udev = interface_to_usbdev(intf); | 1481 | struct usb_device *udev = interface_to_usbdev(intf); |
1483 | int status; | 1482 | int status; |
1484 | 1483 | ||
1485 | udev->last_busy = jiffies; | 1484 | usb_mark_last_busy(udev); |
1486 | atomic_dec(&intf->pm_usage_cnt); | 1485 | atomic_dec(&intf->pm_usage_cnt); |
1487 | status = pm_runtime_put_sync(&intf->dev); | 1486 | status = pm_runtime_put_sync(&intf->dev); |
1488 | dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", | 1487 | dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n", |
@@ -1512,8 +1511,8 @@ void usb_autopm_put_interface_async(struct usb_interface *intf) | |||
1512 | unsigned long last_busy; | 1511 | unsigned long last_busy; |
1513 | int status = 0; | 1512 | int status = 0; |
1514 | 1513 | ||
1515 | last_busy = udev->last_busy; | 1514 | last_busy = udev->dev.power.last_busy; |
1516 | udev->last_busy = jiffies; | 1515 | usb_mark_last_busy(udev); |
1517 | atomic_dec(&intf->pm_usage_cnt); | 1516 | atomic_dec(&intf->pm_usage_cnt); |
1518 | pm_runtime_put_noidle(&intf->dev); | 1517 | pm_runtime_put_noidle(&intf->dev); |
1519 | 1518 | ||
@@ -1554,7 +1553,7 @@ void usb_autopm_put_interface_no_suspend(struct usb_interface *intf) | |||
1554 | { | 1553 | { |
1555 | struct usb_device *udev = interface_to_usbdev(intf); | 1554 | struct usb_device *udev = interface_to_usbdev(intf); |
1556 | 1555 | ||
1557 | udev->last_busy = jiffies; | 1556 | usb_mark_last_busy(udev); |
1558 | atomic_dec(&intf->pm_usage_cnt); | 1557 | atomic_dec(&intf->pm_usage_cnt); |
1559 | pm_runtime_put_noidle(&intf->dev); | 1558 | pm_runtime_put_noidle(&intf->dev); |
1560 | } | 1559 | } |
@@ -1641,7 +1640,7 @@ void usb_autopm_get_interface_no_resume(struct usb_interface *intf) | |||
1641 | { | 1640 | { |
1642 | struct usb_device *udev = interface_to_usbdev(intf); | 1641 | struct usb_device *udev = interface_to_usbdev(intf); |
1643 | 1642 | ||
1644 | udev->last_busy = jiffies; | 1643 | usb_mark_last_busy(udev); |
1645 | atomic_inc(&intf->pm_usage_cnt); | 1644 | atomic_inc(&intf->pm_usage_cnt); |
1646 | pm_runtime_get_noresume(&intf->dev); | 1645 | pm_runtime_get_noresume(&intf->dev); |
1647 | } | 1646 | } |
@@ -1697,7 +1696,7 @@ static int autosuspend_check(struct usb_device *udev) | |||
1697 | * enough, queue a delayed autosuspend request. | 1696 | * enough, queue a delayed autosuspend request. |
1698 | */ | 1697 | */ |
1699 | j = ACCESS_ONCE(jiffies); | 1698 | j = ACCESS_ONCE(jiffies); |
1700 | suspend_time = udev->last_busy + udev->autosuspend_delay; | 1699 | suspend_time = udev->dev.power.last_busy + udev->autosuspend_delay; |
1701 | if (time_before(j, suspend_time)) { | 1700 | if (time_before(j, suspend_time)) { |
1702 | pm_schedule_suspend(&udev->dev, jiffies_to_msecs( | 1701 | pm_schedule_suspend(&udev->dev, jiffies_to_msecs( |
1703 | round_jiffies_up_relative(suspend_time - j))); | 1702 | round_jiffies_up_relative(suspend_time - j))); |
@@ -1725,13 +1724,13 @@ static int usb_runtime_suspend(struct device *dev) | |||
1725 | * away. | 1724 | * away. |
1726 | */ | 1725 | */ |
1727 | if (status) { | 1726 | if (status) { |
1728 | udev->last_busy = jiffies + | 1727 | udev->dev.power.last_busy = jiffies + |
1729 | (udev->autosuspend_delay == 0 ? HZ/2 : 0); | 1728 | (udev->autosuspend_delay == 0 ? HZ/2 : 0); |
1730 | } | 1729 | } |
1731 | 1730 | ||
1732 | /* Prevent the parent from suspending immediately after */ | 1731 | /* Prevent the parent from suspending immediately after */ |
1733 | else if (udev->parent) | 1732 | else if (udev->parent) |
1734 | udev->parent->last_busy = jiffies; | 1733 | usb_mark_last_busy(udev->parent); |
1735 | 1734 | ||
1736 | return status; | 1735 | return status; |
1737 | } | 1736 | } |
@@ -1745,7 +1744,7 @@ static int usb_runtime_resume(struct device *dev) | |||
1745 | * and all its interfaces. | 1744 | * and all its interfaces. |
1746 | */ | 1745 | */ |
1747 | status = usb_resume_both(udev, PMSG_AUTO_RESUME); | 1746 | status = usb_resume_both(udev, PMSG_AUTO_RESUME); |
1748 | udev->last_busy = jiffies; | 1747 | usb_mark_last_busy(udev); |
1749 | return status; | 1748 | return status; |
1750 | } | 1749 | } |
1751 | 1750 | ||
diff --git a/drivers/usb/core/hcd-pci.c b/drivers/usb/core/hcd-pci.c index 3799573bd38..b55d46070a2 100644 --- a/drivers/usb/core/hcd-pci.c +++ b/drivers/usb/core/hcd-pci.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/pci.h> | 21 | #include <linux/pci.h> |
22 | #include <linux/pm_runtime.h> | ||
23 | #include <linux/usb.h> | 22 | #include <linux/usb.h> |
24 | #include <linux/usb/hcd.h> | 23 | #include <linux/usb/hcd.h> |
25 | 24 | ||
diff --git a/drivers/usb/core/hcd.c b/drivers/usb/core/hcd.c index 61800f77dac..e70aeaf3dc1 100644 --- a/drivers/usb/core/hcd.c +++ b/drivers/usb/core/hcd.c | |||
@@ -38,7 +38,6 @@ | |||
38 | #include <asm/unaligned.h> | 38 | #include <asm/unaligned.h> |
39 | #include <linux/platform_device.h> | 39 | #include <linux/platform_device.h> |
40 | #include <linux/workqueue.h> | 40 | #include <linux/workqueue.h> |
41 | #include <linux/pm_runtime.h> | ||
42 | 41 | ||
43 | #include <linux/usb.h> | 42 | #include <linux/usb.h> |
44 | #include <linux/usb/hcd.h> | 43 | #include <linux/usb/hcd.h> |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 27115b45edc..7c2405eccc4 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
@@ -24,7 +24,6 @@ | |||
24 | #include <linux/kthread.h> | 24 | #include <linux/kthread.h> |
25 | #include <linux/mutex.h> | 25 | #include <linux/mutex.h> |
26 | #include <linux/freezer.h> | 26 | #include <linux/freezer.h> |
27 | #include <linux/pm_runtime.h> | ||
28 | 27 | ||
29 | #include <asm/uaccess.h> | 28 | #include <asm/uaccess.h> |
30 | #include <asm/byteorder.h> | 29 | #include <asm/byteorder.h> |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index f377e49fcb3..83248742382 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
@@ -12,7 +12,6 @@ | |||
12 | #include <linux/ctype.h> | 12 | #include <linux/ctype.h> |
13 | #include <linux/nls.h> | 13 | #include <linux/nls.h> |
14 | #include <linux/device.h> | 14 | #include <linux/device.h> |
15 | #include <linux/pm_runtime.h> | ||
16 | #include <linux/scatterlist.h> | 15 | #include <linux/scatterlist.h> |
17 | #include <linux/usb/quirks.h> | 16 | #include <linux/usb/quirks.h> |
18 | #include <linux/usb/hcd.h> /* for usbcore internals */ | 17 | #include <linux/usb/hcd.h> /* for usbcore internals */ |
diff --git a/include/linux/usb.h b/include/linux/usb.h index 35fe6ab222b..7d22b3340a7 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/completion.h> /* for struct completion */ | 20 | #include <linux/completion.h> /* for struct completion */ |
21 | #include <linux/sched.h> /* for current && schedule_timeout */ | 21 | #include <linux/sched.h> /* for current && schedule_timeout */ |
22 | #include <linux/mutex.h> /* for struct mutex */ | 22 | #include <linux/mutex.h> /* for struct mutex */ |
23 | #include <linux/pm_runtime.h> /* for runtime PM */ | ||
23 | 24 | ||
24 | struct usb_device; | 25 | struct usb_device; |
25 | struct usb_driver; | 26 | struct usb_driver; |
@@ -407,7 +408,6 @@ struct usb_tt; | |||
407 | * @quirks: quirks of the whole device | 408 | * @quirks: quirks of the whole device |
408 | * @urbnum: number of URBs submitted for the whole device | 409 | * @urbnum: number of URBs submitted for the whole device |
409 | * @active_duration: total time device is not suspended | 410 | * @active_duration: total time device is not suspended |
410 | * @last_busy: time of last use | ||
411 | * @autosuspend_delay: in jiffies | 411 | * @autosuspend_delay: in jiffies |
412 | * @connect_time: time device was first connected | 412 | * @connect_time: time device was first connected |
413 | * @do_remote_wakeup: remote wakeup should be enabled | 413 | * @do_remote_wakeup: remote wakeup should be enabled |
@@ -481,7 +481,6 @@ struct usb_device { | |||
481 | unsigned long active_duration; | 481 | unsigned long active_duration; |
482 | 482 | ||
483 | #ifdef CONFIG_PM | 483 | #ifdef CONFIG_PM |
484 | unsigned long last_busy; | ||
485 | int autosuspend_delay; | 484 | int autosuspend_delay; |
486 | unsigned long connect_time; | 485 | unsigned long connect_time; |
487 | 486 | ||
@@ -527,7 +526,7 @@ extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf); | |||
527 | 526 | ||
528 | static inline void usb_mark_last_busy(struct usb_device *udev) | 527 | static inline void usb_mark_last_busy(struct usb_device *udev) |
529 | { | 528 | { |
530 | udev->last_busy = jiffies; | 529 | pm_runtime_mark_last_busy(&udev->dev); |
531 | } | 530 | } |
532 | 531 | ||
533 | #else | 532 | #else |