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>
This commit is contained in:
parent
045cac6b3b
commit
6ddf27cdbc
6 changed files with 13 additions and 19 deletions
|
@ -27,7 +27,6 @@
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/usb/quirks.h>
|
#include <linux/usb/quirks.h>
|
||||||
#include <linux/usb/hcd.h>
|
#include <linux/usb/hcd.h>
|
||||||
#include <linux/pm_runtime.h>
|
|
||||||
|
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
|
@ -1329,7 +1328,7 @@ int usb_resume(struct device *dev, pm_message_t msg)
|
||||||
pm_runtime_disable(dev);
|
pm_runtime_disable(dev);
|
||||||
pm_runtime_set_active(dev);
|
pm_runtime_set_active(dev);
|
||||||
pm_runtime_enable(dev);
|
pm_runtime_enable(dev);
|
||||||
udev->last_busy = jiffies;
|
usb_mark_last_busy(udev);
|
||||||
do_unbind_rebind(udev, DO_REBIND);
|
do_unbind_rebind(udev, DO_REBIND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1397,7 +1396,7 @@ void usb_autosuspend_device(struct usb_device *udev)
|
||||||
{
|
{
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
udev->last_busy = jiffies;
|
usb_mark_last_busy(udev);
|
||||||
status = pm_runtime_put_sync(&udev->dev);
|
status = pm_runtime_put_sync(&udev->dev);
|
||||||
dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n",
|
dev_vdbg(&udev->dev, "%s: cnt %d -> %d\n",
|
||||||
__func__, atomic_read(&udev->dev.power.usage_count),
|
__func__, atomic_read(&udev->dev.power.usage_count),
|
||||||
|
@ -1482,7 +1481,7 @@ void usb_autopm_put_interface(struct usb_interface *intf)
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
struct usb_device *udev = interface_to_usbdev(intf);
|
||||||
int status;
|
int status;
|
||||||
|
|
||||||
udev->last_busy = jiffies;
|
usb_mark_last_busy(udev);
|
||||||
atomic_dec(&intf->pm_usage_cnt);
|
atomic_dec(&intf->pm_usage_cnt);
|
||||||
status = pm_runtime_put_sync(&intf->dev);
|
status = pm_runtime_put_sync(&intf->dev);
|
||||||
dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
|
dev_vdbg(&intf->dev, "%s: cnt %d -> %d\n",
|
||||||
|
@ -1512,8 +1511,8 @@ void usb_autopm_put_interface_async(struct usb_interface *intf)
|
||||||
unsigned long last_busy;
|
unsigned long last_busy;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
|
|
||||||
last_busy = udev->last_busy;
|
last_busy = udev->dev.power.last_busy;
|
||||||
udev->last_busy = jiffies;
|
usb_mark_last_busy(udev);
|
||||||
atomic_dec(&intf->pm_usage_cnt);
|
atomic_dec(&intf->pm_usage_cnt);
|
||||||
pm_runtime_put_noidle(&intf->dev);
|
pm_runtime_put_noidle(&intf->dev);
|
||||||
|
|
||||||
|
@ -1554,7 +1553,7 @@ void usb_autopm_put_interface_no_suspend(struct usb_interface *intf)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
struct usb_device *udev = interface_to_usbdev(intf);
|
||||||
|
|
||||||
udev->last_busy = jiffies;
|
usb_mark_last_busy(udev);
|
||||||
atomic_dec(&intf->pm_usage_cnt);
|
atomic_dec(&intf->pm_usage_cnt);
|
||||||
pm_runtime_put_noidle(&intf->dev);
|
pm_runtime_put_noidle(&intf->dev);
|
||||||
}
|
}
|
||||||
|
@ -1641,7 +1640,7 @@ void usb_autopm_get_interface_no_resume(struct usb_interface *intf)
|
||||||
{
|
{
|
||||||
struct usb_device *udev = interface_to_usbdev(intf);
|
struct usb_device *udev = interface_to_usbdev(intf);
|
||||||
|
|
||||||
udev->last_busy = jiffies;
|
usb_mark_last_busy(udev);
|
||||||
atomic_inc(&intf->pm_usage_cnt);
|
atomic_inc(&intf->pm_usage_cnt);
|
||||||
pm_runtime_get_noresume(&intf->dev);
|
pm_runtime_get_noresume(&intf->dev);
|
||||||
}
|
}
|
||||||
|
@ -1697,7 +1696,7 @@ static int autosuspend_check(struct usb_device *udev)
|
||||||
* enough, queue a delayed autosuspend request.
|
* enough, queue a delayed autosuspend request.
|
||||||
*/
|
*/
|
||||||
j = ACCESS_ONCE(jiffies);
|
j = ACCESS_ONCE(jiffies);
|
||||||
suspend_time = udev->last_busy + udev->autosuspend_delay;
|
suspend_time = udev->dev.power.last_busy + udev->autosuspend_delay;
|
||||||
if (time_before(j, suspend_time)) {
|
if (time_before(j, suspend_time)) {
|
||||||
pm_schedule_suspend(&udev->dev, jiffies_to_msecs(
|
pm_schedule_suspend(&udev->dev, jiffies_to_msecs(
|
||||||
round_jiffies_up_relative(suspend_time - j)));
|
round_jiffies_up_relative(suspend_time - j)));
|
||||||
|
@ -1725,13 +1724,13 @@ static int usb_runtime_suspend(struct device *dev)
|
||||||
* away.
|
* away.
|
||||||
*/
|
*/
|
||||||
if (status) {
|
if (status) {
|
||||||
udev->last_busy = jiffies +
|
udev->dev.power.last_busy = jiffies +
|
||||||
(udev->autosuspend_delay == 0 ? HZ/2 : 0);
|
(udev->autosuspend_delay == 0 ? HZ/2 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Prevent the parent from suspending immediately after */
|
/* Prevent the parent from suspending immediately after */
|
||||||
else if (udev->parent)
|
else if (udev->parent)
|
||||||
udev->parent->last_busy = jiffies;
|
usb_mark_last_busy(udev->parent);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
@ -1745,7 +1744,7 @@ static int usb_runtime_resume(struct device *dev)
|
||||||
* and all its interfaces.
|
* and all its interfaces.
|
||||||
*/
|
*/
|
||||||
status = usb_resume_both(udev, PMSG_AUTO_RESUME);
|
status = usb_resume_both(udev, PMSG_AUTO_RESUME);
|
||||||
udev->last_busy = jiffies;
|
usb_mark_last_busy(udev);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,7 +19,6 @@
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/pci.h>
|
#include <linux/pci.h>
|
||||||
#include <linux/pm_runtime.h>
|
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/usb/hcd.h>
|
#include <linux/usb/hcd.h>
|
||||||
|
|
||||||
|
|
|
@ -38,7 +38,6 @@
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
#include <linux/platform_device.h>
|
#include <linux/platform_device.h>
|
||||||
#include <linux/workqueue.h>
|
#include <linux/workqueue.h>
|
||||||
#include <linux/pm_runtime.h>
|
|
||||||
|
|
||||||
#include <linux/usb.h>
|
#include <linux/usb.h>
|
||||||
#include <linux/usb/hcd.h>
|
#include <linux/usb/hcd.h>
|
||||||
|
|
|
@ -24,7 +24,6 @@
|
||||||
#include <linux/kthread.h>
|
#include <linux/kthread.h>
|
||||||
#include <linux/mutex.h>
|
#include <linux/mutex.h>
|
||||||
#include <linux/freezer.h>
|
#include <linux/freezer.h>
|
||||||
#include <linux/pm_runtime.h>
|
|
||||||
|
|
||||||
#include <asm/uaccess.h>
|
#include <asm/uaccess.h>
|
||||||
#include <asm/byteorder.h>
|
#include <asm/byteorder.h>
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include <linux/ctype.h>
|
#include <linux/ctype.h>
|
||||||
#include <linux/nls.h>
|
#include <linux/nls.h>
|
||||||
#include <linux/device.h>
|
#include <linux/device.h>
|
||||||
#include <linux/pm_runtime.h>
|
|
||||||
#include <linux/scatterlist.h>
|
#include <linux/scatterlist.h>
|
||||||
#include <linux/usb/quirks.h>
|
#include <linux/usb/quirks.h>
|
||||||
#include <linux/usb/hcd.h> /* for usbcore internals */
|
#include <linux/usb/hcd.h> /* for usbcore internals */
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
#include <linux/completion.h> /* for struct completion */
|
#include <linux/completion.h> /* for struct completion */
|
||||||
#include <linux/sched.h> /* for current && schedule_timeout */
|
#include <linux/sched.h> /* for current && schedule_timeout */
|
||||||
#include <linux/mutex.h> /* for struct mutex */
|
#include <linux/mutex.h> /* for struct mutex */
|
||||||
|
#include <linux/pm_runtime.h> /* for runtime PM */
|
||||||
|
|
||||||
struct usb_device;
|
struct usb_device;
|
||||||
struct usb_driver;
|
struct usb_driver;
|
||||||
|
@ -407,7 +408,6 @@ struct usb_tt;
|
||||||
* @quirks: quirks of the whole device
|
* @quirks: quirks of the whole device
|
||||||
* @urbnum: number of URBs submitted for the whole device
|
* @urbnum: number of URBs submitted for the whole device
|
||||||
* @active_duration: total time device is not suspended
|
* @active_duration: total time device is not suspended
|
||||||
* @last_busy: time of last use
|
|
||||||
* @autosuspend_delay: in jiffies
|
* @autosuspend_delay: in jiffies
|
||||||
* @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
|
||||||
|
@ -481,7 +481,6 @@ struct usb_device {
|
||||||
unsigned long active_duration;
|
unsigned long active_duration;
|
||||||
|
|
||||||
#ifdef CONFIG_PM
|
#ifdef CONFIG_PM
|
||||||
unsigned long last_busy;
|
|
||||||
int autosuspend_delay;
|
int autosuspend_delay;
|
||||||
unsigned long connect_time;
|
unsigned long connect_time;
|
||||||
|
|
||||||
|
@ -527,7 +526,7 @@ extern void usb_autopm_put_interface_no_suspend(struct usb_interface *intf);
|
||||||
|
|
||||||
static inline void usb_mark_last_busy(struct usb_device *udev)
|
static inline void usb_mark_last_busy(struct usb_device *udev)
|
||||||
{
|
{
|
||||||
udev->last_busy = jiffies;
|
pm_runtime_mark_last_busy(&udev->dev);
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
Loading…
Add table
Reference in a new issue