]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - include/linux/pm_runtime.h
PM / Runtime: Document power.runtime_auto and related functions
[mirror_ubuntu-bionic-kernel.git] / include / linux / pm_runtime.h
CommitLineData
5e928f77
RW
1/*
2 * pm_runtime.h - Device run-time power management helper functions.
3 *
4 * Copyright (C) 2009 Rafael J. Wysocki <rjw@sisk.pl>
5 *
6 * This file is released under the GPLv2.
7 */
8
9#ifndef _LINUX_PM_RUNTIME_H
10#define _LINUX_PM_RUNTIME_H
11
12#include <linux/device.h>
13#include <linux/pm.h>
14
15#ifdef CONFIG_PM_RUNTIME
16
17extern struct workqueue_struct *pm_wq;
18
19extern int pm_runtime_idle(struct device *dev);
20extern int pm_runtime_suspend(struct device *dev);
21extern int pm_runtime_resume(struct device *dev);
22extern int pm_request_idle(struct device *dev);
23extern int pm_schedule_suspend(struct device *dev, unsigned int delay);
24extern int pm_request_resume(struct device *dev);
25extern int __pm_runtime_get(struct device *dev, bool sync);
26extern int __pm_runtime_put(struct device *dev, bool sync);
27extern int __pm_runtime_set_status(struct device *dev, unsigned int status);
28extern int pm_runtime_barrier(struct device *dev);
29extern void pm_runtime_enable(struct device *dev);
30extern void __pm_runtime_disable(struct device *dev, bool check_resume);
53823639
RW
31extern void pm_runtime_allow(struct device *dev);
32extern void pm_runtime_forbid(struct device *dev);
5e928f77
RW
33
34static inline bool pm_children_suspended(struct device *dev)
35{
36 return dev->power.ignore_children
37 || !atomic_read(&dev->power.child_count);
38}
39
40static inline void pm_suspend_ignore_children(struct device *dev, bool enable)
41{
42 dev->power.ignore_children = enable;
43}
44
45static inline void pm_runtime_get_noresume(struct device *dev)
46{
47 atomic_inc(&dev->power.usage_count);
48}
49
50static inline void pm_runtime_put_noidle(struct device *dev)
51{
52 atomic_add_unless(&dev->power.usage_count, -1, 0);
53}
54
7a1a8eb5
RW
55static inline bool device_run_wake(struct device *dev)
56{
57 return dev->power.run_wake;
58}
59
60static inline void device_set_run_wake(struct device *dev, bool enable)
61{
62 dev->power.run_wake = enable;
63}
64
5e928f77
RW
65#else /* !CONFIG_PM_RUNTIME */
66
67static inline int pm_runtime_idle(struct device *dev) { return -ENOSYS; }
68static inline int pm_runtime_suspend(struct device *dev) { return -ENOSYS; }
69static inline int pm_runtime_resume(struct device *dev) { return 0; }
70static inline int pm_request_idle(struct device *dev) { return -ENOSYS; }
71static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
72{
73 return -ENOSYS;
74}
75static inline int pm_request_resume(struct device *dev) { return 0; }
76static inline int __pm_runtime_get(struct device *dev, bool sync) { return 1; }
77static inline int __pm_runtime_put(struct device *dev, bool sync) { return 0; }
78static inline int __pm_runtime_set_status(struct device *dev,
79 unsigned int status) { return 0; }
80static inline int pm_runtime_barrier(struct device *dev) { return 0; }
81static inline void pm_runtime_enable(struct device *dev) {}
82static inline void __pm_runtime_disable(struct device *dev, bool c) {}
53823639
RW
83static inline void pm_runtime_allow(struct device *dev) {}
84static inline void pm_runtime_forbid(struct device *dev) {}
5e928f77
RW
85
86static inline bool pm_children_suspended(struct device *dev) { return false; }
87static inline void pm_suspend_ignore_children(struct device *dev, bool en) {}
88static inline void pm_runtime_get_noresume(struct device *dev) {}
89static inline void pm_runtime_put_noidle(struct device *dev) {}
7a1a8eb5
RW
90static inline bool device_run_wake(struct device *dev) { return false; }
91static inline void device_set_run_wake(struct device *dev, bool enable) {}
5e928f77
RW
92
93#endif /* !CONFIG_PM_RUNTIME */
94
95static inline int pm_runtime_get(struct device *dev)
96{
97 return __pm_runtime_get(dev, false);
98}
99
100static inline int pm_runtime_get_sync(struct device *dev)
101{
102 return __pm_runtime_get(dev, true);
103}
104
105static inline int pm_runtime_put(struct device *dev)
106{
107 return __pm_runtime_put(dev, false);
108}
109
110static inline int pm_runtime_put_sync(struct device *dev)
111{
112 return __pm_runtime_put(dev, true);
113}
114
115static inline int pm_runtime_set_active(struct device *dev)
116{
117 return __pm_runtime_set_status(dev, RPM_ACTIVE);
118}
119
120static inline void pm_runtime_set_suspended(struct device *dev)
121{
122 __pm_runtime_set_status(dev, RPM_SUSPENDED);
123}
124
125static inline void pm_runtime_disable(struct device *dev)
126{
127 __pm_runtime_disable(dev, true);
128}
129
130#endif