xref: /linux-6.15/include/linux/pm_runtime.h (revision 1476bb20)
155716d26SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
25e928f77SRafael J. Wysocki /*
35e928f77SRafael J. Wysocki  * pm_runtime.h - Device run-time power management helper functions.
45e928f77SRafael J. Wysocki  *
55e928f77SRafael J. Wysocki  * Copyright (C) 2009 Rafael J. Wysocki <[email protected]>
65e928f77SRafael J. Wysocki  */
75e928f77SRafael J. Wysocki 
85e928f77SRafael J. Wysocki #ifndef _LINUX_PM_RUNTIME_H
95e928f77SRafael J. Wysocki #define _LINUX_PM_RUNTIME_H
105e928f77SRafael J. Wysocki 
115e928f77SRafael J. Wysocki #include <linux/device.h>
12246359d3SPaul Gortmaker #include <linux/notifier.h>
135e928f77SRafael J. Wysocki #include <linux/pm.h>
145e928f77SRafael J. Wysocki 
1515bcb91dSAlan Stern #include <linux/jiffies.h>
1615bcb91dSAlan Stern 
173f9af051SAlan Stern /* Runtime PM flag argument bits */
183f9af051SAlan Stern #define RPM_ASYNC		0x01	/* Request is asynchronous */
193f9af051SAlan Stern #define RPM_NOWAIT		0x02	/* Don't wait for concurrent
203f9af051SAlan Stern 					    state change */
21140a6c94SAlan Stern #define RPM_GET_PUT		0x04	/* Increment/decrement the
22140a6c94SAlan Stern 					    usage_count */
2315bcb91dSAlan Stern #define RPM_AUTO		0x08	/* Use autosuspend_delay */
243f9af051SAlan Stern 
259d861919SPaul Cercueil /*
269d861919SPaul Cercueil  * Use this for defining a set of PM operations to be used in all situations
279d861919SPaul Cercueil  * (system suspend, hibernation or runtime PM).
289d861919SPaul Cercueil  *
299d861919SPaul Cercueil  * Note that the behaviour differs from the deprecated UNIVERSAL_DEV_PM_OPS()
309d861919SPaul Cercueil  * macro, which uses the provided callbacks for both runtime PM and system
319d861919SPaul Cercueil  * sleep, while DEFINE_RUNTIME_DEV_PM_OPS() uses pm_runtime_force_suspend()
329d861919SPaul Cercueil  * and pm_runtime_force_resume() for its system sleep callbacks.
33d59ff7d9SPaul Cercueil  *
34d59ff7d9SPaul Cercueil  * If the underlying dev_pm_ops struct symbol has to be exported, use
35d59ff7d9SPaul Cercueil  * EXPORT_RUNTIME_DEV_PM_OPS() or EXPORT_GPL_RUNTIME_DEV_PM_OPS() instead.
369d861919SPaul Cercueil  */
379d861919SPaul Cercueil #define DEFINE_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
389d861919SPaul Cercueil 	_DEFINE_DEV_PM_OPS(name, pm_runtime_force_suspend, \
399d861919SPaul Cercueil 			   pm_runtime_force_resume, suspend_fn, \
409d861919SPaul Cercueil 			   resume_fn, idle_fn)
419d861919SPaul Cercueil 
42d59ff7d9SPaul Cercueil #define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
4334e1ed18SPaul Cercueil 	EXPORT_DEV_PM_OPS(name) = { \
4434e1ed18SPaul Cercueil 		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
4534e1ed18SPaul Cercueil 	}
46d59ff7d9SPaul Cercueil #define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
4734e1ed18SPaul Cercueil 	EXPORT_GPL_DEV_PM_OPS(name) = { \
4834e1ed18SPaul Cercueil 		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
4934e1ed18SPaul Cercueil 	}
50a8e2512eSJonathan Cameron #define EXPORT_NS_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
5134e1ed18SPaul Cercueil 	EXPORT_NS_DEV_PM_OPS(name, ns) = { \
5234e1ed18SPaul Cercueil 		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
5334e1ed18SPaul Cercueil 	}
54a8e2512eSJonathan Cameron #define EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
5534e1ed18SPaul Cercueil 	EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
5634e1ed18SPaul Cercueil 		RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
5734e1ed18SPaul Cercueil 	}
58d59ff7d9SPaul Cercueil 
59717e5d45SUlf Hansson #ifdef CONFIG_PM
6028cb5ef1SRafael J. Wysocki extern struct workqueue_struct *pm_wq;
6128cb5ef1SRafael J. Wysocki 
queue_pm_work(struct work_struct * work)6228cb5ef1SRafael J. Wysocki static inline bool queue_pm_work(struct work_struct *work)
6328cb5ef1SRafael J. Wysocki {
6428cb5ef1SRafael J. Wysocki 	return queue_work(pm_wq, work);
6528cb5ef1SRafael J. Wysocki }
6628cb5ef1SRafael J. Wysocki 
67717e5d45SUlf Hansson extern int pm_generic_runtime_suspend(struct device *dev);
68717e5d45SUlf Hansson extern int pm_generic_runtime_resume(struct device *dev);
69eeb87d17SRafael J. Wysocki extern bool pm_runtime_need_not_resume(struct device *dev);
7037f20416SUlf Hansson extern int pm_runtime_force_suspend(struct device *dev);
7137f20416SUlf Hansson extern int pm_runtime_force_resume(struct device *dev);
725e928f77SRafael J. Wysocki 
73140a6c94SAlan Stern extern int __pm_runtime_idle(struct device *dev, int rpmflags);
74140a6c94SAlan Stern extern int __pm_runtime_suspend(struct device *dev, int rpmflags);
75140a6c94SAlan Stern extern int __pm_runtime_resume(struct device *dev, int rpmflags);
76c0ef3df8SSakari Ailus extern int pm_runtime_get_if_active(struct device *dev);
77c0ef3df8SSakari Ailus extern int pm_runtime_get_if_in_use(struct device *dev);
785e928f77SRafael J. Wysocki extern int pm_schedule_suspend(struct device *dev, unsigned int delay);
795e928f77SRafael J. Wysocki extern int __pm_runtime_set_status(struct device *dev, unsigned int status);
805e928f77SRafael J. Wysocki extern int pm_runtime_barrier(struct device *dev);
81520a552fSRafael J. Wysocki extern bool pm_runtime_block_if_disabled(struct device *dev);
823e5eee14SRafael J. Wysocki extern void pm_runtime_unblock(struct device *dev);
835e928f77SRafael J. Wysocki extern void pm_runtime_enable(struct device *dev);
845e928f77SRafael J. Wysocki extern void __pm_runtime_disable(struct device *dev, bool check_resume);
8553823639SRafael J. Wysocki extern void pm_runtime_allow(struct device *dev);
8653823639SRafael J. Wysocki extern void pm_runtime_forbid(struct device *dev);
877490e442SAlan Stern extern void pm_runtime_no_callbacks(struct device *dev);
88c7b61de5SAlan Stern extern void pm_runtime_irq_safe(struct device *dev);
8915bcb91dSAlan Stern extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
9015bcb91dSAlan Stern extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay);
918234f673SVincent Guittot extern u64 pm_runtime_autosuspend_expiration(struct device *dev);
92e823407fSMing Lei extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
93b06c0b2fSRafael J. Wysocki extern void pm_runtime_get_suppliers(struct device *dev);
94b06c0b2fSRafael J. Wysocki extern void pm_runtime_put_suppliers(struct device *dev);
95baa8809fSRafael J. Wysocki extern void pm_runtime_new_link(struct device *dev);
96e0e398e2SRafael J. Wysocki extern void pm_runtime_drop_link(struct device_link *link);
9707358194SRafael J. Wysocki extern void pm_runtime_release_supplier(struct device_link *link);
985e928f77SRafael J. Wysocki 
99b3636a3aSDmitry Baryshkov extern int devm_pm_runtime_enable(struct device *dev);
100b3636a3aSDmitry Baryshkov 
101403d2d11SRafael J. Wysocki /**
102403d2d11SRafael J. Wysocki  * pm_suspend_ignore_children - Set runtime PM behavior regarding children.
103403d2d11SRafael J. Wysocki  * @dev: Target device.
104403d2d11SRafael J. Wysocki  * @enable: Whether or not to ignore possible dependencies on children.
105403d2d11SRafael J. Wysocki  *
106403d2d11SRafael J. Wysocki  * The dependencies of @dev on its children will not be taken into account by
107403d2d11SRafael J. Wysocki  * the runtime PM framework going forward if @enable is %true, or they will
108403d2d11SRafael J. Wysocki  * be taken into account otherwise.
109403d2d11SRafael J. Wysocki  */
pm_suspend_ignore_children(struct device * dev,bool enable)110372a12edSUlf Hansson static inline void pm_suspend_ignore_children(struct device *dev, bool enable)
111372a12edSUlf Hansson {
112372a12edSUlf Hansson 	dev->power.ignore_children = enable;
113372a12edSUlf Hansson }
114372a12edSUlf Hansson 
115403d2d11SRafael J. Wysocki /**
116403d2d11SRafael J. Wysocki  * pm_runtime_get_noresume - Bump up runtime PM usage counter of a device.
117403d2d11SRafael J. Wysocki  * @dev: Target device.
118403d2d11SRafael J. Wysocki  */
pm_runtime_get_noresume(struct device * dev)1195e928f77SRafael J. Wysocki static inline void pm_runtime_get_noresume(struct device *dev)
1205e928f77SRafael J. Wysocki {
1215e928f77SRafael J. Wysocki 	atomic_inc(&dev->power.usage_count);
1225e928f77SRafael J. Wysocki }
1235e928f77SRafael J. Wysocki 
124403d2d11SRafael J. Wysocki /**
125403d2d11SRafael J. Wysocki  * pm_runtime_put_noidle - Drop runtime PM usage counter of a device.
126403d2d11SRafael J. Wysocki  * @dev: Target device.
127403d2d11SRafael J. Wysocki  *
128403d2d11SRafael J. Wysocki  * Decrement the runtime PM usage counter of @dev unless it is 0 already.
129403d2d11SRafael J. Wysocki  */
pm_runtime_put_noidle(struct device * dev)1305e928f77SRafael J. Wysocki static inline void pm_runtime_put_noidle(struct device *dev)
1315e928f77SRafael J. Wysocki {
1325e928f77SRafael J. Wysocki 	atomic_add_unless(&dev->power.usage_count, -1, 0);
1335e928f77SRafael J. Wysocki }
1345e928f77SRafael J. Wysocki 
135403d2d11SRafael J. Wysocki /**
136403d2d11SRafael J. Wysocki  * pm_runtime_suspended - Check whether or not a device is runtime-suspended.
137403d2d11SRafael J. Wysocki  * @dev: Target device.
138403d2d11SRafael J. Wysocki  *
139403d2d11SRafael J. Wysocki  * Return %true if runtime PM is enabled for @dev and its runtime PM status is
140403d2d11SRafael J. Wysocki  * %RPM_SUSPENDED, or %false otherwise.
141403d2d11SRafael J. Wysocki  *
142403d2d11SRafael J. Wysocki  * Note that the return value of this function can only be trusted if it is
143403d2d11SRafael J. Wysocki  * called under the runtime PM lock of @dev or under conditions in which
144403d2d11SRafael J. Wysocki  * runtime PM cannot be either disabled or enabled for @dev and its runtime PM
145403d2d11SRafael J. Wysocki  * status cannot change.
146403d2d11SRafael J. Wysocki  */
pm_runtime_suspended(struct device * dev)147d690b2cdSRafael J. Wysocki static inline bool pm_runtime_suspended(struct device *dev)
148d690b2cdSRafael J. Wysocki {
149f08f5a0aSRafael J. Wysocki 	return dev->power.runtime_status == RPM_SUSPENDED
150f08f5a0aSRafael J. Wysocki 		&& !dev->power.disable_depth;
151d690b2cdSRafael J. Wysocki }
152d690b2cdSRafael J. Wysocki 
153403d2d11SRafael J. Wysocki /**
154403d2d11SRafael J. Wysocki  * pm_runtime_active - Check whether or not a device is runtime-active.
155403d2d11SRafael J. Wysocki  * @dev: Target device.
156403d2d11SRafael J. Wysocki  *
157444dd878SRafael J. Wysocki  * Return %true if runtime PM is disabled for @dev or its runtime PM status is
158403d2d11SRafael J. Wysocki  * %RPM_ACTIVE, or %false otherwise.
159403d2d11SRafael J. Wysocki  *
160403d2d11SRafael J. Wysocki  * Note that the return value of this function can only be trusted if it is
161403d2d11SRafael J. Wysocki  * called under the runtime PM lock of @dev or under conditions in which
162403d2d11SRafael J. Wysocki  * runtime PM cannot be either disabled or enabled for @dev and its runtime PM
163403d2d11SRafael J. Wysocki  * status cannot change.
164403d2d11SRafael J. Wysocki  */
pm_runtime_active(struct device * dev)165fbadc58dSShuoX Liu static inline bool pm_runtime_active(struct device *dev)
166fbadc58dSShuoX Liu {
167fbadc58dSShuoX Liu 	return dev->power.runtime_status == RPM_ACTIVE
168fbadc58dSShuoX Liu 		|| dev->power.disable_depth;
169fbadc58dSShuoX Liu }
170fbadc58dSShuoX Liu 
171403d2d11SRafael J. Wysocki /**
172403d2d11SRafael J. Wysocki  * pm_runtime_status_suspended - Check if runtime PM status is "suspended".
173403d2d11SRafael J. Wysocki  * @dev: Target device.
174403d2d11SRafael J. Wysocki  *
175403d2d11SRafael J. Wysocki  * Return %true if the runtime PM status of @dev is %RPM_SUSPENDED, or %false
176403d2d11SRafael J. Wysocki  * otherwise, regardless of whether or not runtime PM has been enabled for @dev.
177403d2d11SRafael J. Wysocki  *
178403d2d11SRafael J. Wysocki  * Note that the return value of this function can only be trusted if it is
179403d2d11SRafael J. Wysocki  * called under the runtime PM lock of @dev or under conditions in which the
180403d2d11SRafael J. Wysocki  * runtime PM status of @dev cannot change.
181403d2d11SRafael J. Wysocki  */
pm_runtime_status_suspended(struct device * dev)182f3393b62SKevin Hilman static inline bool pm_runtime_status_suspended(struct device *dev)
183f3393b62SKevin Hilman {
184f3393b62SKevin Hilman 	return dev->power.runtime_status == RPM_SUSPENDED;
185f3393b62SKevin Hilman }
186f3393b62SKevin Hilman 
187403d2d11SRafael J. Wysocki /**
188403d2d11SRafael J. Wysocki  * pm_runtime_enabled - Check if runtime PM is enabled.
189403d2d11SRafael J. Wysocki  * @dev: Target device.
190403d2d11SRafael J. Wysocki  *
191403d2d11SRafael J. Wysocki  * Return %true if runtime PM is enabled for @dev or %false otherwise.
192403d2d11SRafael J. Wysocki  *
193403d2d11SRafael J. Wysocki  * Note that the return value of this function can only be trusted if it is
194403d2d11SRafael J. Wysocki  * called under the runtime PM lock of @dev or under conditions in which
195403d2d11SRafael J. Wysocki  * runtime PM cannot be either disabled or enabled for @dev.
196403d2d11SRafael J. Wysocki  */
pm_runtime_enabled(struct device * dev)1974b31db8aSRafael J. Wysocki static inline bool pm_runtime_enabled(struct device *dev)
1984b31db8aSRafael J. Wysocki {
1994b31db8aSRafael J. Wysocki 	return !dev->power.disable_depth;
2004b31db8aSRafael J. Wysocki }
2014b31db8aSRafael J. Wysocki 
202403d2d11SRafael J. Wysocki /**
203*1476bb20SRafael J. Wysocki  * pm_runtime_blocked - Check if runtime PM enabling is blocked.
204*1476bb20SRafael J. Wysocki  * @dev: Target device.
205*1476bb20SRafael J. Wysocki  *
206*1476bb20SRafael J. Wysocki  * Do not call this function outside system suspend/resume code paths.
207*1476bb20SRafael J. Wysocki  */
pm_runtime_blocked(struct device * dev)208*1476bb20SRafael J. Wysocki static inline bool pm_runtime_blocked(struct device *dev)
209*1476bb20SRafael J. Wysocki {
210*1476bb20SRafael J. Wysocki 	return dev->power.last_status == RPM_BLOCKED;
211*1476bb20SRafael J. Wysocki }
212*1476bb20SRafael J. Wysocki 
213*1476bb20SRafael J. Wysocki /**
214403d2d11SRafael J. Wysocki  * pm_runtime_has_no_callbacks - Check if runtime PM callbacks may be present.
215403d2d11SRafael J. Wysocki  * @dev: Target device.
216403d2d11SRafael J. Wysocki  *
217403d2d11SRafael J. Wysocki  * Return %true if @dev is a special device without runtime PM callbacks or
218403d2d11SRafael J. Wysocki  * %false otherwise.
219403d2d11SRafael J. Wysocki  */
pm_runtime_has_no_callbacks(struct device * dev)2209a787546SRafael J. Wysocki static inline bool pm_runtime_has_no_callbacks(struct device *dev)
221cb8f51bdSRafael J. Wysocki {
2229a787546SRafael J. Wysocki 	return dev->power.no_callbacks;
223cb8f51bdSRafael J. Wysocki }
224cb8f51bdSRafael J. Wysocki 
225403d2d11SRafael J. Wysocki /**
226403d2d11SRafael J. Wysocki  * pm_runtime_mark_last_busy - Update the last access time of a device.
227403d2d11SRafael J. Wysocki  * @dev: Target device.
228403d2d11SRafael J. Wysocki  *
229403d2d11SRafael J. Wysocki  * Update the last access time of @dev used by the runtime PM autosuspend
230403d2d11SRafael J. Wysocki  * mechanism to the current time as returned by ktime_get_mono_fast_ns().
231403d2d11SRafael J. Wysocki  */
pm_runtime_mark_last_busy(struct device * dev)23215bcb91dSAlan Stern static inline void pm_runtime_mark_last_busy(struct device *dev)
23315bcb91dSAlan Stern {
23415efb47dSVincent Guittot 	WRITE_ONCE(dev->power.last_busy, ktime_get_mono_fast_ns());
23515bcb91dSAlan Stern }
23615bcb91dSAlan Stern 
237403d2d11SRafael J. Wysocki /**
238403d2d11SRafael J. Wysocki  * pm_runtime_is_irq_safe - Check if runtime PM can work in interrupt context.
239403d2d11SRafael J. Wysocki  * @dev: Target device.
240403d2d11SRafael J. Wysocki  *
241403d2d11SRafael J. Wysocki  * Return %true if @dev has been marked as an "IRQ-safe" device (with respect
242403d2d11SRafael J. Wysocki  * to runtime PM), in which case its runtime PM callabcks can be expected to
243403d2d11SRafael J. Wysocki  * work correctly when invoked from interrupt handlers.
244403d2d11SRafael J. Wysocki  */
pm_runtime_is_irq_safe(struct device * dev)2453fb1581eSKrzysztof Kozlowski static inline bool pm_runtime_is_irq_safe(struct device *dev)
2463fb1581eSKrzysztof Kozlowski {
2473fb1581eSKrzysztof Kozlowski 	return dev->power.irq_safe;
2483fb1581eSKrzysztof Kozlowski }
2493fb1581eSKrzysztof Kozlowski 
2508a62ffe2SVincent Guittot extern u64 pm_runtime_suspended_time(struct device *dev);
2518a62ffe2SVincent Guittot 
252d30d819dSRafael J. Wysocki #else /* !CONFIG_PM */
253d30d819dSRafael J. Wysocki 
queue_pm_work(struct work_struct * work)254d30d819dSRafael J. Wysocki static inline bool queue_pm_work(struct work_struct *work) { return false; }
255d30d819dSRafael J. Wysocki 
pm_generic_runtime_suspend(struct device * dev)256d30d819dSRafael J. Wysocki static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
pm_generic_runtime_resume(struct device * dev)257d30d819dSRafael J. Wysocki static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
pm_runtime_need_not_resume(struct device * dev)258eeb87d17SRafael J. Wysocki static inline bool pm_runtime_need_not_resume(struct device *dev) {return true; }
pm_runtime_force_suspend(struct device * dev)259d30d819dSRafael J. Wysocki static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
pm_runtime_force_resume(struct device * dev)260d30d819dSRafael J. Wysocki static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
2615e928f77SRafael J. Wysocki 
__pm_runtime_idle(struct device * dev,int rpmflags)262140a6c94SAlan Stern static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
263140a6c94SAlan Stern {
264140a6c94SAlan Stern 	return -ENOSYS;
265140a6c94SAlan Stern }
__pm_runtime_suspend(struct device * dev,int rpmflags)266140a6c94SAlan Stern static inline int __pm_runtime_suspend(struct device *dev, int rpmflags)
267140a6c94SAlan Stern {
268140a6c94SAlan Stern 	return -ENOSYS;
269140a6c94SAlan Stern }
__pm_runtime_resume(struct device * dev,int rpmflags)270140a6c94SAlan Stern static inline int __pm_runtime_resume(struct device *dev, int rpmflags)
271140a6c94SAlan Stern {
272140a6c94SAlan Stern 	return 1;
273140a6c94SAlan Stern }
pm_schedule_suspend(struct device * dev,unsigned int delay)2745e928f77SRafael J. Wysocki static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
2755e928f77SRafael J. Wysocki {
2765e928f77SRafael J. Wysocki 	return -ENOSYS;
2775e928f77SRafael J. Wysocki }
pm_runtime_get_if_in_use(struct device * dev)278a436b6a1SRafael J. Wysocki static inline int pm_runtime_get_if_in_use(struct device *dev)
279a436b6a1SRafael J. Wysocki {
280a436b6a1SRafael J. Wysocki 	return -EINVAL;
281a436b6a1SRafael J. Wysocki }
pm_runtime_get_if_active(struct device * dev)282c0ef3df8SSakari Ailus static inline int pm_runtime_get_if_active(struct device *dev)
283c111566bSSakari Ailus {
284c111566bSSakari Ailus 	return -EINVAL;
285c111566bSSakari Ailus }
__pm_runtime_set_status(struct device * dev,unsigned int status)2865e928f77SRafael J. Wysocki static inline int __pm_runtime_set_status(struct device *dev,
2875e928f77SRafael J. Wysocki 					    unsigned int status) { return 0; }
pm_runtime_barrier(struct device * dev)2885e928f77SRafael J. Wysocki static inline int pm_runtime_barrier(struct device *dev) { return 0; }
pm_runtime_block_if_disabled(struct device * dev)289520a552fSRafael J. Wysocki static inline bool pm_runtime_block_if_disabled(struct device *dev) { return true; }
pm_runtime_unblock(struct device * dev)2903e5eee14SRafael J. Wysocki static inline void pm_runtime_unblock(struct device *dev) {}
pm_runtime_enable(struct device * dev)2915e928f77SRafael J. Wysocki static inline void pm_runtime_enable(struct device *dev) {}
__pm_runtime_disable(struct device * dev,bool c)2925e928f77SRafael J. Wysocki static inline void __pm_runtime_disable(struct device *dev, bool c) {}
pm_runtime_blocked(struct device * dev)293758cc55cSRafael J. Wysocki static inline bool pm_runtime_blocked(struct device *dev) { return true; }
pm_runtime_allow(struct device * dev)29453823639SRafael J. Wysocki static inline void pm_runtime_allow(struct device *dev) {}
pm_runtime_forbid(struct device * dev)29553823639SRafael J. Wysocki static inline void pm_runtime_forbid(struct device *dev) {}
2965e928f77SRafael J. Wysocki 
devm_pm_runtime_enable(struct device * dev)297b3636a3aSDmitry Baryshkov static inline int devm_pm_runtime_enable(struct device *dev) { return 0; }
298b3636a3aSDmitry Baryshkov 
pm_suspend_ignore_children(struct device * dev,bool enable)299372a12edSUlf Hansson static inline void pm_suspend_ignore_children(struct device *dev, bool enable) {}
pm_runtime_get_noresume(struct device * dev)3005e928f77SRafael J. Wysocki static inline void pm_runtime_get_noresume(struct device *dev) {}
pm_runtime_put_noidle(struct device * dev)3015e928f77SRafael J. Wysocki static inline void pm_runtime_put_noidle(struct device *dev) {}
pm_runtime_suspended(struct device * dev)302d690b2cdSRafael J. Wysocki static inline bool pm_runtime_suspended(struct device *dev) { return false; }
pm_runtime_active(struct device * dev)303fbadc58dSShuoX Liu static inline bool pm_runtime_active(struct device *dev) { return true; }
pm_runtime_status_suspended(struct device * dev)304f3393b62SKevin Hilman static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
pm_runtime_enabled(struct device * dev)3054b31db8aSRafael J. Wysocki static inline bool pm_runtime_enabled(struct device *dev) { return false; }
3065e928f77SRafael J. Wysocki 
pm_runtime_no_callbacks(struct device * dev)3077490e442SAlan Stern static inline void pm_runtime_no_callbacks(struct device *dev) {}
pm_runtime_irq_safe(struct device * dev)308c7b61de5SAlan Stern static inline void pm_runtime_irq_safe(struct device *dev) {}
pm_runtime_is_irq_safe(struct device * dev)3093fb1581eSKrzysztof Kozlowski static inline bool pm_runtime_is_irq_safe(struct device *dev) { return false; }
3102f60ba70SRafael J. Wysocki 
pm_runtime_has_no_callbacks(struct device * dev)311953c1fd9SYueHaibing static inline bool pm_runtime_has_no_callbacks(struct device *dev) { return false; }
pm_runtime_mark_last_busy(struct device * dev)31215bcb91dSAlan Stern static inline void pm_runtime_mark_last_busy(struct device *dev) {}
__pm_runtime_use_autosuspend(struct device * dev,bool use)31315bcb91dSAlan Stern static inline void __pm_runtime_use_autosuspend(struct device *dev,
31415bcb91dSAlan Stern 						bool use) {}
pm_runtime_set_autosuspend_delay(struct device * dev,int delay)31515bcb91dSAlan Stern static inline void pm_runtime_set_autosuspend_delay(struct device *dev,
31615bcb91dSAlan Stern 						int delay) {}
pm_runtime_autosuspend_expiration(struct device * dev)3178234f673SVincent Guittot static inline u64 pm_runtime_autosuspend_expiration(
31815bcb91dSAlan Stern 				struct device *dev) { return 0; }
pm_runtime_set_memalloc_noio(struct device * dev,bool enable)319e823407fSMing Lei static inline void pm_runtime_set_memalloc_noio(struct device *dev,
320e823407fSMing Lei 						bool enable){}
pm_runtime_get_suppliers(struct device * dev)321b06c0b2fSRafael J. Wysocki static inline void pm_runtime_get_suppliers(struct device *dev) {}
pm_runtime_put_suppliers(struct device * dev)322b06c0b2fSRafael J. Wysocki static inline void pm_runtime_put_suppliers(struct device *dev) {}
pm_runtime_new_link(struct device * dev)323baa8809fSRafael J. Wysocki static inline void pm_runtime_new_link(struct device *dev) {}
pm_runtime_drop_link(struct device_link * link)324e0e398e2SRafael J. Wysocki static inline void pm_runtime_drop_link(struct device_link *link) {}
pm_runtime_release_supplier(struct device_link * link)32507358194SRafael J. Wysocki static inline void pm_runtime_release_supplier(struct device_link *link) {}
32615bcb91dSAlan Stern 
327d30d819dSRafael J. Wysocki #endif /* !CONFIG_PM */
3285e928f77SRafael J. Wysocki 
329403d2d11SRafael J. Wysocki /**
330403d2d11SRafael J. Wysocki  * pm_runtime_idle - Conditionally set up autosuspend of a device or suspend it.
331403d2d11SRafael J. Wysocki  * @dev: Target device.
332403d2d11SRafael J. Wysocki  *
333403d2d11SRafael J. Wysocki  * Invoke the "idle check" callback of @dev and, depending on its return value,
334403d2d11SRafael J. Wysocki  * set up autosuspend of @dev or suspend it (depending on whether or not
335403d2d11SRafael J. Wysocki  * autosuspend has been enabled for it).
336403d2d11SRafael J. Wysocki  */
pm_runtime_idle(struct device * dev)337140a6c94SAlan Stern static inline int pm_runtime_idle(struct device *dev)
338140a6c94SAlan Stern {
339140a6c94SAlan Stern 	return __pm_runtime_idle(dev, 0);
340140a6c94SAlan Stern }
341140a6c94SAlan Stern 
342403d2d11SRafael J. Wysocki /**
343403d2d11SRafael J. Wysocki  * pm_runtime_suspend - Suspend a device synchronously.
344403d2d11SRafael J. Wysocki  * @dev: Target device.
345403d2d11SRafael J. Wysocki  */
pm_runtime_suspend(struct device * dev)346140a6c94SAlan Stern static inline int pm_runtime_suspend(struct device *dev)
347140a6c94SAlan Stern {
348140a6c94SAlan Stern 	return __pm_runtime_suspend(dev, 0);
349140a6c94SAlan Stern }
350140a6c94SAlan Stern 
351403d2d11SRafael J. Wysocki /**
352403d2d11SRafael J. Wysocki  * pm_runtime_autosuspend - Set up autosuspend of a device or suspend it.
353403d2d11SRafael J. Wysocki  * @dev: Target device.
354403d2d11SRafael J. Wysocki  *
355403d2d11SRafael J. Wysocki  * Set up autosuspend of @dev or suspend it (depending on whether or not
356403d2d11SRafael J. Wysocki  * autosuspend is enabled for it) without engaging its "idle check" callback.
357403d2d11SRafael J. Wysocki  */
pm_runtime_autosuspend(struct device * dev)35815bcb91dSAlan Stern static inline int pm_runtime_autosuspend(struct device *dev)
35915bcb91dSAlan Stern {
36015bcb91dSAlan Stern 	return __pm_runtime_suspend(dev, RPM_AUTO);
36115bcb91dSAlan Stern }
36215bcb91dSAlan Stern 
363403d2d11SRafael J. Wysocki /**
364403d2d11SRafael J. Wysocki  * pm_runtime_resume - Resume a device synchronously.
365403d2d11SRafael J. Wysocki  * @dev: Target device.
366403d2d11SRafael J. Wysocki  */
pm_runtime_resume(struct device * dev)367140a6c94SAlan Stern static inline int pm_runtime_resume(struct device *dev)
368140a6c94SAlan Stern {
369140a6c94SAlan Stern 	return __pm_runtime_resume(dev, 0);
370140a6c94SAlan Stern }
371140a6c94SAlan Stern 
372403d2d11SRafael J. Wysocki /**
373403d2d11SRafael J. Wysocki  * pm_request_idle - Queue up "idle check" execution for a device.
374403d2d11SRafael J. Wysocki  * @dev: Target device.
375403d2d11SRafael J. Wysocki  *
376403d2d11SRafael J. Wysocki  * Queue up a work item to run an equivalent of pm_runtime_idle() for @dev
377403d2d11SRafael J. Wysocki  * asynchronously.
378403d2d11SRafael J. Wysocki  */
pm_request_idle(struct device * dev)379140a6c94SAlan Stern static inline int pm_request_idle(struct device *dev)
380140a6c94SAlan Stern {
381140a6c94SAlan Stern 	return __pm_runtime_idle(dev, RPM_ASYNC);
382140a6c94SAlan Stern }
383140a6c94SAlan Stern 
384403d2d11SRafael J. Wysocki /**
385403d2d11SRafael J. Wysocki  * pm_request_resume - Queue up runtime-resume of a device.
386403d2d11SRafael J. Wysocki  * @dev: Target device.
387403d2d11SRafael J. Wysocki  */
pm_request_resume(struct device * dev)388140a6c94SAlan Stern static inline int pm_request_resume(struct device *dev)
389140a6c94SAlan Stern {
390140a6c94SAlan Stern 	return __pm_runtime_resume(dev, RPM_ASYNC);
391140a6c94SAlan Stern }
392140a6c94SAlan Stern 
393403d2d11SRafael J. Wysocki /**
394403d2d11SRafael J. Wysocki  * pm_request_autosuspend - Queue up autosuspend of a device.
395403d2d11SRafael J. Wysocki  * @dev: Target device.
396403d2d11SRafael J. Wysocki  *
397403d2d11SRafael J. Wysocki  * Queue up a work item to run an equivalent pm_runtime_autosuspend() for @dev
398403d2d11SRafael J. Wysocki  * asynchronously.
399403d2d11SRafael J. Wysocki  */
pm_request_autosuspend(struct device * dev)4005fc62aadSMing Lei static inline int pm_request_autosuspend(struct device *dev)
4015fc62aadSMing Lei {
4025fc62aadSMing Lei 	return __pm_runtime_suspend(dev, RPM_ASYNC | RPM_AUTO);
4035fc62aadSMing Lei }
4045fc62aadSMing Lei 
405403d2d11SRafael J. Wysocki /**
406403d2d11SRafael J. Wysocki  * pm_runtime_get - Bump up usage counter and queue up resume of a device.
407403d2d11SRafael J. Wysocki  * @dev: Target device.
408403d2d11SRafael J. Wysocki  *
409403d2d11SRafael J. Wysocki  * Bump up the runtime PM usage counter of @dev and queue up a work item to
410403d2d11SRafael J. Wysocki  * carry out runtime-resume of it.
411403d2d11SRafael J. Wysocki  */
pm_runtime_get(struct device * dev)4125e928f77SRafael J. Wysocki static inline int pm_runtime_get(struct device *dev)
4135e928f77SRafael J. Wysocki {
414140a6c94SAlan Stern 	return __pm_runtime_resume(dev, RPM_GET_PUT | RPM_ASYNC);
4155e928f77SRafael J. Wysocki }
4165e928f77SRafael J. Wysocki 
417403d2d11SRafael J. Wysocki /**
418403d2d11SRafael J. Wysocki  * pm_runtime_get_sync - Bump up usage counter of a device and resume it.
419403d2d11SRafael J. Wysocki  * @dev: Target device.
420403d2d11SRafael J. Wysocki  *
421403d2d11SRafael J. Wysocki  * Bump up the runtime PM usage counter of @dev and carry out runtime-resume of
422403d2d11SRafael J. Wysocki  * it synchronously.
423403d2d11SRafael J. Wysocki  *
424403d2d11SRafael J. Wysocki  * The possible return values of this function are the same as for
425403d2d11SRafael J. Wysocki  * pm_runtime_resume() and the runtime PM usage counter of @dev remains
426403d2d11SRafael J. Wysocki  * incremented in all cases, even if it returns an error code.
427c58e7ed2SKrzysztof Kozlowski  * Consider using pm_runtime_resume_and_get() instead of it, especially
428c58e7ed2SKrzysztof Kozlowski  * if its return value is checked by the caller, as this is likely to result
429c58e7ed2SKrzysztof Kozlowski  * in cleaner code.
430403d2d11SRafael J. Wysocki  */
pm_runtime_get_sync(struct device * dev)4315e928f77SRafael J. Wysocki static inline int pm_runtime_get_sync(struct device *dev)
4325e928f77SRafael J. Wysocki {
433140a6c94SAlan Stern 	return __pm_runtime_resume(dev, RPM_GET_PUT);
4345e928f77SRafael J. Wysocki }
4355e928f77SRafael J. Wysocki 
436403d2d11SRafael J. Wysocki /**
437dd8088d5SZhang Qilong  * pm_runtime_resume_and_get - Bump up usage counter of a device and resume it.
438dd8088d5SZhang Qilong  * @dev: Target device.
439dd8088d5SZhang Qilong  *
440dd8088d5SZhang Qilong  * Resume @dev synchronously and if that is successful, increment its runtime
441dd8088d5SZhang Qilong  * PM usage counter. Return 0 if the runtime PM usage counter of @dev has been
442dd8088d5SZhang Qilong  * incremented or a negative error code otherwise.
443dd8088d5SZhang Qilong  */
pm_runtime_resume_and_get(struct device * dev)444dd8088d5SZhang Qilong static inline int pm_runtime_resume_and_get(struct device *dev)
445dd8088d5SZhang Qilong {
446dd8088d5SZhang Qilong 	int ret;
447dd8088d5SZhang Qilong 
448dd8088d5SZhang Qilong 	ret = __pm_runtime_resume(dev, RPM_GET_PUT);
449dd8088d5SZhang Qilong 	if (ret < 0) {
450dd8088d5SZhang Qilong 		pm_runtime_put_noidle(dev);
451dd8088d5SZhang Qilong 		return ret;
452dd8088d5SZhang Qilong 	}
453dd8088d5SZhang Qilong 
454dd8088d5SZhang Qilong 	return 0;
455dd8088d5SZhang Qilong }
456dd8088d5SZhang Qilong 
457dd8088d5SZhang Qilong /**
458403d2d11SRafael J. Wysocki  * pm_runtime_put - Drop device usage counter and queue up "idle check" if 0.
459403d2d11SRafael J. Wysocki  * @dev: Target device.
460403d2d11SRafael J. Wysocki  *
461403d2d11SRafael J. Wysocki  * Decrement the runtime PM usage counter of @dev and if it turns out to be
462403d2d11SRafael J. Wysocki  * equal to 0, queue up a work item for @dev like in pm_request_idle().
463403d2d11SRafael J. Wysocki  */
pm_runtime_put(struct device * dev)4645e928f77SRafael J. Wysocki static inline int pm_runtime_put(struct device *dev)
4655e928f77SRafael J. Wysocki {
466140a6c94SAlan Stern 	return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
4675e928f77SRafael J. Wysocki }
4685e928f77SRafael J. Wysocki 
469403d2d11SRafael J. Wysocki /**
470b7d46644SSakari Ailus  * __pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
471b7d46644SSakari Ailus  * @dev: Target device.
472b7d46644SSakari Ailus  *
473b7d46644SSakari Ailus  * Decrement the runtime PM usage counter of @dev and if it turns out to be
474b7d46644SSakari Ailus  * equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
475b7d46644SSakari Ailus  */
__pm_runtime_put_autosuspend(struct device * dev)476b7d46644SSakari Ailus static inline int __pm_runtime_put_autosuspend(struct device *dev)
477b7d46644SSakari Ailus {
478b7d46644SSakari Ailus 	return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
479b7d46644SSakari Ailus }
480b7d46644SSakari Ailus 
481b7d46644SSakari Ailus /**
482403d2d11SRafael J. Wysocki  * pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
483403d2d11SRafael J. Wysocki  * @dev: Target device.
484403d2d11SRafael J. Wysocki  *
485403d2d11SRafael J. Wysocki  * Decrement the runtime PM usage counter of @dev and if it turns out to be
486403d2d11SRafael J. Wysocki  * equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
487403d2d11SRafael J. Wysocki  */
pm_runtime_put_autosuspend(struct device * dev)48815bcb91dSAlan Stern static inline int pm_runtime_put_autosuspend(struct device *dev)
48915bcb91dSAlan Stern {
49015bcb91dSAlan Stern 	return __pm_runtime_suspend(dev,
49115bcb91dSAlan Stern 	    RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
49215bcb91dSAlan Stern }
49315bcb91dSAlan Stern 
494403d2d11SRafael J. Wysocki /**
495403d2d11SRafael J. Wysocki  * pm_runtime_put_sync - Drop device usage counter and run "idle check" if 0.
496403d2d11SRafael J. Wysocki  * @dev: Target device.
497403d2d11SRafael J. Wysocki  *
498403d2d11SRafael J. Wysocki  * Decrement the runtime PM usage counter of @dev and if it turns out to be
499403d2d11SRafael J. Wysocki  * equal to 0, invoke the "idle check" callback of @dev and, depending on its
500403d2d11SRafael J. Wysocki  * return value, set up autosuspend of @dev or suspend it (depending on whether
501403d2d11SRafael J. Wysocki  * or not autosuspend has been enabled for it).
502403d2d11SRafael J. Wysocki  *
503403d2d11SRafael J. Wysocki  * The possible return values of this function are the same as for
504403d2d11SRafael J. Wysocki  * pm_runtime_idle() and the runtime PM usage counter of @dev remains
505403d2d11SRafael J. Wysocki  * decremented in all cases, even if it returns an error code.
506403d2d11SRafael J. Wysocki  */
pm_runtime_put_sync(struct device * dev)5075e928f77SRafael J. Wysocki static inline int pm_runtime_put_sync(struct device *dev)
5085e928f77SRafael J. Wysocki {
509140a6c94SAlan Stern 	return __pm_runtime_idle(dev, RPM_GET_PUT);
5105e928f77SRafael J. Wysocki }
5115e928f77SRafael J. Wysocki 
512403d2d11SRafael J. Wysocki /**
513403d2d11SRafael J. Wysocki  * pm_runtime_put_sync_suspend - Drop device usage counter and suspend if 0.
514403d2d11SRafael J. Wysocki  * @dev: Target device.
515403d2d11SRafael J. Wysocki  *
516403d2d11SRafael J. Wysocki  * Decrement the runtime PM usage counter of @dev and if it turns out to be
517403d2d11SRafael J. Wysocki  * equal to 0, carry out runtime-suspend of @dev synchronously.
518403d2d11SRafael J. Wysocki  *
519403d2d11SRafael J. Wysocki  * The possible return values of this function are the same as for
520403d2d11SRafael J. Wysocki  * pm_runtime_suspend() and the runtime PM usage counter of @dev remains
521403d2d11SRafael J. Wysocki  * decremented in all cases, even if it returns an error code.
522403d2d11SRafael J. Wysocki  */
pm_runtime_put_sync_suspend(struct device * dev)523c7b61de5SAlan Stern static inline int pm_runtime_put_sync_suspend(struct device *dev)
524c7b61de5SAlan Stern {
525c7b61de5SAlan Stern 	return __pm_runtime_suspend(dev, RPM_GET_PUT);
526c7b61de5SAlan Stern }
527c7b61de5SAlan Stern 
528403d2d11SRafael J. Wysocki /**
529403d2d11SRafael J. Wysocki  * pm_runtime_put_sync_autosuspend - Drop device usage counter and autosuspend if 0.
530403d2d11SRafael J. Wysocki  * @dev: Target device.
531403d2d11SRafael J. Wysocki  *
532403d2d11SRafael J. Wysocki  * Decrement the runtime PM usage counter of @dev and if it turns out to be
533403d2d11SRafael J. Wysocki  * equal to 0, set up autosuspend of @dev or suspend it synchronously (depending
534403d2d11SRafael J. Wysocki  * on whether or not autosuspend has been enabled for it).
535403d2d11SRafael J. Wysocki  *
536403d2d11SRafael J. Wysocki  * The possible return values of this function are the same as for
537403d2d11SRafael J. Wysocki  * pm_runtime_autosuspend() and the runtime PM usage counter of @dev remains
538403d2d11SRafael J. Wysocki  * decremented in all cases, even if it returns an error code.
539403d2d11SRafael J. Wysocki  */
pm_runtime_put_sync_autosuspend(struct device * dev)54015bcb91dSAlan Stern static inline int pm_runtime_put_sync_autosuspend(struct device *dev)
54115bcb91dSAlan Stern {
54215bcb91dSAlan Stern 	return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_AUTO);
54315bcb91dSAlan Stern }
54415bcb91dSAlan Stern 
545403d2d11SRafael J. Wysocki /**
546403d2d11SRafael J. Wysocki  * pm_runtime_set_active - Set runtime PM status to "active".
547403d2d11SRafael J. Wysocki  * @dev: Target device.
548403d2d11SRafael J. Wysocki  *
549403d2d11SRafael J. Wysocki  * Set the runtime PM status of @dev to %RPM_ACTIVE and ensure that dependencies
550403d2d11SRafael J. Wysocki  * of it will be taken into account.
551403d2d11SRafael J. Wysocki  *
552403d2d11SRafael J. Wysocki  * It is not valid to call this function for devices with runtime PM enabled.
553403d2d11SRafael J. Wysocki  */
pm_runtime_set_active(struct device * dev)5545e928f77SRafael J. Wysocki static inline int pm_runtime_set_active(struct device *dev)
5555e928f77SRafael J. Wysocki {
5565e928f77SRafael J. Wysocki 	return __pm_runtime_set_status(dev, RPM_ACTIVE);
5575e928f77SRafael J. Wysocki }
5585e928f77SRafael J. Wysocki 
559403d2d11SRafael J. Wysocki /**
560aa9c9b3fSBean Huo  * pm_runtime_set_suspended - Set runtime PM status to "suspended".
561403d2d11SRafael J. Wysocki  * @dev: Target device.
562403d2d11SRafael J. Wysocki  *
563403d2d11SRafael J. Wysocki  * Set the runtime PM status of @dev to %RPM_SUSPENDED and ensure that
564403d2d11SRafael J. Wysocki  * dependencies of it will be taken into account.
565403d2d11SRafael J. Wysocki  *
566403d2d11SRafael J. Wysocki  * It is not valid to call this function for devices with runtime PM enabled.
567403d2d11SRafael J. Wysocki  */
pm_runtime_set_suspended(struct device * dev)568b1a60995SUlf Hansson static inline int pm_runtime_set_suspended(struct device *dev)
5695e928f77SRafael J. Wysocki {
570b1a60995SUlf Hansson 	return __pm_runtime_set_status(dev, RPM_SUSPENDED);
5715e928f77SRafael J. Wysocki }
5725e928f77SRafael J. Wysocki 
573403d2d11SRafael J. Wysocki /**
574403d2d11SRafael J. Wysocki  * pm_runtime_disable - Disable runtime PM for a device.
575403d2d11SRafael J. Wysocki  * @dev: Target device.
576403d2d11SRafael J. Wysocki  *
577258e231dSRafael J. Wysocki  * Prevent the runtime PM framework from working with @dev by incrementing its
578258e231dSRafael J. Wysocki  * "disable" counter.
579403d2d11SRafael J. Wysocki  *
580258e231dSRafael J. Wysocki  * If the counter is zero when this function runs and there is a pending runtime
581258e231dSRafael J. Wysocki  * resume request for @dev, it will be resumed.  If the counter is still zero at
582258e231dSRafael J. Wysocki  * that point, all of the pending runtime PM requests for @dev will be canceled
583258e231dSRafael J. Wysocki  * and all runtime PM operations in progress involving it will be waited for to
584258e231dSRafael J. Wysocki  * complete.
585258e231dSRafael J. Wysocki  *
586258e231dSRafael J. Wysocki  * For each invocation of this function for @dev, there must be a matching
587258e231dSRafael J. Wysocki  * pm_runtime_enable() call, so that runtime PM is eventually enabled for it
588258e231dSRafael J. Wysocki  * again.
589403d2d11SRafael J. Wysocki  */
pm_runtime_disable(struct device * dev)5905e928f77SRafael J. Wysocki static inline void pm_runtime_disable(struct device *dev)
5915e928f77SRafael J. Wysocki {
5925e928f77SRafael J. Wysocki 	__pm_runtime_disable(dev, true);
5935e928f77SRafael J. Wysocki }
5945e928f77SRafael J. Wysocki 
595403d2d11SRafael J. Wysocki /**
596403d2d11SRafael J. Wysocki  * pm_runtime_use_autosuspend - Allow autosuspend to be used for a device.
597403d2d11SRafael J. Wysocki  * @dev: Target device.
598403d2d11SRafael J. Wysocki  *
599403d2d11SRafael J. Wysocki  * Allow the runtime PM autosuspend mechanism to be used for @dev whenever
600403d2d11SRafael J. Wysocki  * requested (or "autosuspend" will be handled as direct runtime-suspend for
601403d2d11SRafael J. Wysocki  * it).
602b4060db9SDouglas Anderson  *
603b4060db9SDouglas Anderson  * NOTE: It's important to undo this with pm_runtime_dont_use_autosuspend()
604b4060db9SDouglas Anderson  * at driver exit time unless your driver initially enabled pm_runtime
605b4060db9SDouglas Anderson  * with devm_pm_runtime_enable() (which handles it for you).
606403d2d11SRafael J. Wysocki  */
pm_runtime_use_autosuspend(struct device * dev)60715bcb91dSAlan Stern static inline void pm_runtime_use_autosuspend(struct device *dev)
60815bcb91dSAlan Stern {
60915bcb91dSAlan Stern 	__pm_runtime_use_autosuspend(dev, true);
61015bcb91dSAlan Stern }
61115bcb91dSAlan Stern 
612403d2d11SRafael J. Wysocki /**
613403d2d11SRafael J. Wysocki  * pm_runtime_dont_use_autosuspend - Prevent autosuspend from being used.
614403d2d11SRafael J. Wysocki  * @dev: Target device.
615403d2d11SRafael J. Wysocki  *
616403d2d11SRafael J. Wysocki  * Prevent the runtime PM autosuspend mechanism from being used for @dev which
617403d2d11SRafael J. Wysocki  * means that "autosuspend" will be handled as direct runtime-suspend for it
618403d2d11SRafael J. Wysocki  * going forward.
619403d2d11SRafael J. Wysocki  */
pm_runtime_dont_use_autosuspend(struct device * dev)62015bcb91dSAlan Stern static inline void pm_runtime_dont_use_autosuspend(struct device *dev)
62115bcb91dSAlan Stern {
62215bcb91dSAlan Stern 	__pm_runtime_use_autosuspend(dev, false);
62315bcb91dSAlan Stern }
62415bcb91dSAlan Stern 
6255e928f77SRafael J. Wysocki #endif
626