pm_runtime.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * pm_runtime.h - Device run-time power management helper functions.
  4. *
  5. * Copyright (C) 2009 Rafael J. Wysocki <[email protected]>
  6. */
  7. #ifndef _LINUX_PM_RUNTIME_H
  8. #define _LINUX_PM_RUNTIME_H
  9. #include <linux/device.h>
  10. #include <linux/notifier.h>
  11. #include <linux/pm.h>
  12. #include <linux/jiffies.h>
  13. /* Runtime PM flag argument bits */
  14. #define RPM_ASYNC 0x01 /* Request is asynchronous */
  15. #define RPM_NOWAIT 0x02 /* Don't wait for concurrent
  16. state change */
  17. #define RPM_GET_PUT 0x04 /* Increment/decrement the
  18. usage_count */
  19. #define RPM_AUTO 0x08 /* Use autosuspend_delay */
  20. /*
  21. * Use this for defining a set of PM operations to be used in all situations
  22. * (system suspend, hibernation or runtime PM).
  23. *
  24. * Note that the behaviour differs from the deprecated UNIVERSAL_DEV_PM_OPS()
  25. * macro, which uses the provided callbacks for both runtime PM and system
  26. * sleep, while DEFINE_RUNTIME_DEV_PM_OPS() uses pm_runtime_force_suspend()
  27. * and pm_runtime_force_resume() for its system sleep callbacks.
  28. *
  29. * If the underlying dev_pm_ops struct symbol has to be exported, use
  30. * EXPORT_RUNTIME_DEV_PM_OPS() or EXPORT_GPL_RUNTIME_DEV_PM_OPS() instead.
  31. */
  32. #define DEFINE_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
  33. _DEFINE_DEV_PM_OPS(name, pm_runtime_force_suspend, \
  34. pm_runtime_force_resume, suspend_fn, \
  35. resume_fn, idle_fn)
  36. #define EXPORT_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
  37. EXPORT_DEV_PM_OPS(name) = { \
  38. RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
  39. }
  40. #define EXPORT_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn) \
  41. EXPORT_GPL_DEV_PM_OPS(name) = { \
  42. RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
  43. }
  44. #define EXPORT_NS_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
  45. EXPORT_NS_DEV_PM_OPS(name, ns) = { \
  46. RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
  47. }
  48. #define EXPORT_NS_GPL_RUNTIME_DEV_PM_OPS(name, suspend_fn, resume_fn, idle_fn, ns) \
  49. EXPORT_NS_GPL_DEV_PM_OPS(name, ns) = { \
  50. RUNTIME_PM_OPS(suspend_fn, resume_fn, idle_fn) \
  51. }
  52. #ifdef CONFIG_PM
  53. extern struct workqueue_struct *pm_wq;
  54. static inline bool queue_pm_work(struct work_struct *work)
  55. {
  56. return queue_work(pm_wq, work);
  57. }
  58. extern int pm_generic_runtime_suspend(struct device *dev);
  59. extern int pm_generic_runtime_resume(struct device *dev);
  60. extern int pm_runtime_force_suspend(struct device *dev);
  61. extern int pm_runtime_force_resume(struct device *dev);
  62. extern int __pm_runtime_idle(struct device *dev, int rpmflags);
  63. extern int __pm_runtime_suspend(struct device *dev, int rpmflags);
  64. extern int __pm_runtime_resume(struct device *dev, int rpmflags);
  65. extern int pm_runtime_get_if_active(struct device *dev, bool ign_usage_count);
  66. extern int pm_schedule_suspend(struct device *dev, unsigned int delay);
  67. extern int __pm_runtime_set_status(struct device *dev, unsigned int status);
  68. extern int pm_runtime_barrier(struct device *dev);
  69. extern void pm_runtime_enable(struct device *dev);
  70. extern void __pm_runtime_disable(struct device *dev, bool check_resume);
  71. extern void pm_runtime_allow(struct device *dev);
  72. extern void pm_runtime_forbid(struct device *dev);
  73. extern void pm_runtime_no_callbacks(struct device *dev);
  74. extern void pm_runtime_irq_safe(struct device *dev);
  75. extern void __pm_runtime_use_autosuspend(struct device *dev, bool use);
  76. extern void pm_runtime_set_autosuspend_delay(struct device *dev, int delay);
  77. extern u64 pm_runtime_autosuspend_expiration(struct device *dev);
  78. extern void pm_runtime_update_max_time_suspended(struct device *dev,
  79. s64 delta_ns);
  80. extern void pm_runtime_set_memalloc_noio(struct device *dev, bool enable);
  81. extern void pm_runtime_get_suppliers(struct device *dev);
  82. extern void pm_runtime_put_suppliers(struct device *dev);
  83. extern void pm_runtime_new_link(struct device *dev);
  84. extern void pm_runtime_drop_link(struct device_link *link);
  85. extern void pm_runtime_release_supplier(struct device_link *link);
  86. extern int devm_pm_runtime_enable(struct device *dev);
  87. /**
  88. * pm_runtime_get_if_in_use - Conditionally bump up runtime PM usage counter.
  89. * @dev: Target device.
  90. *
  91. * Increment the runtime PM usage counter of @dev if its runtime PM status is
  92. * %RPM_ACTIVE and its runtime PM usage counter is greater than 0.
  93. */
  94. static inline int pm_runtime_get_if_in_use(struct device *dev)
  95. {
  96. return pm_runtime_get_if_active(dev, false);
  97. }
  98. /**
  99. * pm_suspend_ignore_children - Set runtime PM behavior regarding children.
  100. * @dev: Target device.
  101. * @enable: Whether or not to ignore possible dependencies on children.
  102. *
  103. * The dependencies of @dev on its children will not be taken into account by
  104. * the runtime PM framework going forward if @enable is %true, or they will
  105. * be taken into account otherwise.
  106. */
  107. static inline void pm_suspend_ignore_children(struct device *dev, bool enable)
  108. {
  109. dev->power.ignore_children = enable;
  110. }
  111. /**
  112. * pm_runtime_get_noresume - Bump up runtime PM usage counter of a device.
  113. * @dev: Target device.
  114. */
  115. static inline void pm_runtime_get_noresume(struct device *dev)
  116. {
  117. atomic_inc(&dev->power.usage_count);
  118. }
  119. /**
  120. * pm_runtime_put_noidle - Drop runtime PM usage counter of a device.
  121. * @dev: Target device.
  122. *
  123. * Decrement the runtime PM usage counter of @dev unless it is 0 already.
  124. */
  125. static inline void pm_runtime_put_noidle(struct device *dev)
  126. {
  127. atomic_add_unless(&dev->power.usage_count, -1, 0);
  128. }
  129. /**
  130. * pm_runtime_suspended - Check whether or not a device is runtime-suspended.
  131. * @dev: Target device.
  132. *
  133. * Return %true if runtime PM is enabled for @dev and its runtime PM status is
  134. * %RPM_SUSPENDED, or %false otherwise.
  135. *
  136. * Note that the return value of this function can only be trusted if it is
  137. * called under the runtime PM lock of @dev or under conditions in which
  138. * runtime PM cannot be either disabled or enabled for @dev and its runtime PM
  139. * status cannot change.
  140. */
  141. static inline bool pm_runtime_suspended(struct device *dev)
  142. {
  143. return dev->power.runtime_status == RPM_SUSPENDED
  144. && !dev->power.disable_depth;
  145. }
  146. /**
  147. * pm_runtime_active - Check whether or not a device is runtime-active.
  148. * @dev: Target device.
  149. *
  150. * Return %true if runtime PM is disabled for @dev or its runtime PM status is
  151. * %RPM_ACTIVE, or %false otherwise.
  152. *
  153. * Note that the return value of this function can only be trusted if it is
  154. * called under the runtime PM lock of @dev or under conditions in which
  155. * runtime PM cannot be either disabled or enabled for @dev and its runtime PM
  156. * status cannot change.
  157. */
  158. static inline bool pm_runtime_active(struct device *dev)
  159. {
  160. return dev->power.runtime_status == RPM_ACTIVE
  161. || dev->power.disable_depth;
  162. }
  163. /**
  164. * pm_runtime_status_suspended - Check if runtime PM status is "suspended".
  165. * @dev: Target device.
  166. *
  167. * Return %true if the runtime PM status of @dev is %RPM_SUSPENDED, or %false
  168. * otherwise, regardless of whether or not runtime PM has been enabled for @dev.
  169. *
  170. * Note that the return value of this function can only be trusted if it is
  171. * called under the runtime PM lock of @dev or under conditions in which the
  172. * runtime PM status of @dev cannot change.
  173. */
  174. static inline bool pm_runtime_status_suspended(struct device *dev)
  175. {
  176. return dev->power.runtime_status == RPM_SUSPENDED;
  177. }
  178. /**
  179. * pm_runtime_enabled - Check if runtime PM is enabled.
  180. * @dev: Target device.
  181. *
  182. * Return %true if runtime PM is enabled for @dev or %false otherwise.
  183. *
  184. * Note that the return value of this function can only be trusted if it is
  185. * called under the runtime PM lock of @dev or under conditions in which
  186. * runtime PM cannot be either disabled or enabled for @dev.
  187. */
  188. static inline bool pm_runtime_enabled(struct device *dev)
  189. {
  190. return !dev->power.disable_depth;
  191. }
  192. /**
  193. * pm_runtime_has_no_callbacks - Check if runtime PM callbacks may be present.
  194. * @dev: Target device.
  195. *
  196. * Return %true if @dev is a special device without runtime PM callbacks or
  197. * %false otherwise.
  198. */
  199. static inline bool pm_runtime_has_no_callbacks(struct device *dev)
  200. {
  201. return dev->power.no_callbacks;
  202. }
  203. /**
  204. * pm_runtime_mark_last_busy - Update the last access time of a device.
  205. * @dev: Target device.
  206. *
  207. * Update the last access time of @dev used by the runtime PM autosuspend
  208. * mechanism to the current time as returned by ktime_get_mono_fast_ns().
  209. */
  210. static inline void pm_runtime_mark_last_busy(struct device *dev)
  211. {
  212. WRITE_ONCE(dev->power.last_busy, ktime_get_mono_fast_ns());
  213. }
  214. /**
  215. * pm_runtime_is_irq_safe - Check if runtime PM can work in interrupt context.
  216. * @dev: Target device.
  217. *
  218. * Return %true if @dev has been marked as an "IRQ-safe" device (with respect
  219. * to runtime PM), in which case its runtime PM callabcks can be expected to
  220. * work correctly when invoked from interrupt handlers.
  221. */
  222. static inline bool pm_runtime_is_irq_safe(struct device *dev)
  223. {
  224. return dev->power.irq_safe;
  225. }
  226. extern u64 pm_runtime_suspended_time(struct device *dev);
  227. #else /* !CONFIG_PM */
  228. static inline bool queue_pm_work(struct work_struct *work) { return false; }
  229. static inline int pm_generic_runtime_suspend(struct device *dev) { return 0; }
  230. static inline int pm_generic_runtime_resume(struct device *dev) { return 0; }
  231. static inline int pm_runtime_force_suspend(struct device *dev) { return 0; }
  232. static inline int pm_runtime_force_resume(struct device *dev) { return 0; }
  233. static inline int __pm_runtime_idle(struct device *dev, int rpmflags)
  234. {
  235. return -ENOSYS;
  236. }
  237. static inline int __pm_runtime_suspend(struct device *dev, int rpmflags)
  238. {
  239. return -ENOSYS;
  240. }
  241. static inline int __pm_runtime_resume(struct device *dev, int rpmflags)
  242. {
  243. return 1;
  244. }
  245. static inline int pm_schedule_suspend(struct device *dev, unsigned int delay)
  246. {
  247. return -ENOSYS;
  248. }
  249. static inline int pm_runtime_get_if_in_use(struct device *dev)
  250. {
  251. return -EINVAL;
  252. }
  253. static inline int pm_runtime_get_if_active(struct device *dev,
  254. bool ign_usage_count)
  255. {
  256. return -EINVAL;
  257. }
  258. static inline int __pm_runtime_set_status(struct device *dev,
  259. unsigned int status) { return 0; }
  260. static inline int pm_runtime_barrier(struct device *dev) { return 0; }
  261. static inline void pm_runtime_enable(struct device *dev) {}
  262. static inline void __pm_runtime_disable(struct device *dev, bool c) {}
  263. static inline void pm_runtime_allow(struct device *dev) {}
  264. static inline void pm_runtime_forbid(struct device *dev) {}
  265. static inline int devm_pm_runtime_enable(struct device *dev) { return 0; }
  266. static inline void pm_suspend_ignore_children(struct device *dev, bool enable) {}
  267. static inline void pm_runtime_get_noresume(struct device *dev) {}
  268. static inline void pm_runtime_put_noidle(struct device *dev) {}
  269. static inline bool pm_runtime_suspended(struct device *dev) { return false; }
  270. static inline bool pm_runtime_active(struct device *dev) { return true; }
  271. static inline bool pm_runtime_status_suspended(struct device *dev) { return false; }
  272. static inline bool pm_runtime_enabled(struct device *dev) { return false; }
  273. static inline void pm_runtime_no_callbacks(struct device *dev) {}
  274. static inline void pm_runtime_irq_safe(struct device *dev) {}
  275. static inline bool pm_runtime_is_irq_safe(struct device *dev) { return false; }
  276. static inline bool pm_runtime_has_no_callbacks(struct device *dev) { return false; }
  277. static inline void pm_runtime_mark_last_busy(struct device *dev) {}
  278. static inline void __pm_runtime_use_autosuspend(struct device *dev,
  279. bool use) {}
  280. static inline void pm_runtime_set_autosuspend_delay(struct device *dev,
  281. int delay) {}
  282. static inline u64 pm_runtime_autosuspend_expiration(
  283. struct device *dev) { return 0; }
  284. static inline void pm_runtime_set_memalloc_noio(struct device *dev,
  285. bool enable){}
  286. static inline void pm_runtime_get_suppliers(struct device *dev) {}
  287. static inline void pm_runtime_put_suppliers(struct device *dev) {}
  288. static inline void pm_runtime_new_link(struct device *dev) {}
  289. static inline void pm_runtime_drop_link(struct device_link *link) {}
  290. static inline void pm_runtime_release_supplier(struct device_link *link) {}
  291. #endif /* !CONFIG_PM */
  292. /**
  293. * pm_runtime_idle - Conditionally set up autosuspend of a device or suspend it.
  294. * @dev: Target device.
  295. *
  296. * Invoke the "idle check" callback of @dev and, depending on its return value,
  297. * set up autosuspend of @dev or suspend it (depending on whether or not
  298. * autosuspend has been enabled for it).
  299. */
  300. static inline int pm_runtime_idle(struct device *dev)
  301. {
  302. return __pm_runtime_idle(dev, 0);
  303. }
  304. /**
  305. * pm_runtime_suspend - Suspend a device synchronously.
  306. * @dev: Target device.
  307. */
  308. static inline int pm_runtime_suspend(struct device *dev)
  309. {
  310. return __pm_runtime_suspend(dev, 0);
  311. }
  312. /**
  313. * pm_runtime_autosuspend - Set up autosuspend of a device or suspend it.
  314. * @dev: Target device.
  315. *
  316. * Set up autosuspend of @dev or suspend it (depending on whether or not
  317. * autosuspend is enabled for it) without engaging its "idle check" callback.
  318. */
  319. static inline int pm_runtime_autosuspend(struct device *dev)
  320. {
  321. return __pm_runtime_suspend(dev, RPM_AUTO);
  322. }
  323. /**
  324. * pm_runtime_resume - Resume a device synchronously.
  325. * @dev: Target device.
  326. */
  327. static inline int pm_runtime_resume(struct device *dev)
  328. {
  329. return __pm_runtime_resume(dev, 0);
  330. }
  331. /**
  332. * pm_request_idle - Queue up "idle check" execution for a device.
  333. * @dev: Target device.
  334. *
  335. * Queue up a work item to run an equivalent of pm_runtime_idle() for @dev
  336. * asynchronously.
  337. */
  338. static inline int pm_request_idle(struct device *dev)
  339. {
  340. return __pm_runtime_idle(dev, RPM_ASYNC);
  341. }
  342. /**
  343. * pm_request_resume - Queue up runtime-resume of a device.
  344. * @dev: Target device.
  345. */
  346. static inline int pm_request_resume(struct device *dev)
  347. {
  348. return __pm_runtime_resume(dev, RPM_ASYNC);
  349. }
  350. /**
  351. * pm_request_autosuspend - Queue up autosuspend of a device.
  352. * @dev: Target device.
  353. *
  354. * Queue up a work item to run an equivalent pm_runtime_autosuspend() for @dev
  355. * asynchronously.
  356. */
  357. static inline int pm_request_autosuspend(struct device *dev)
  358. {
  359. return __pm_runtime_suspend(dev, RPM_ASYNC | RPM_AUTO);
  360. }
  361. /**
  362. * pm_runtime_get - Bump up usage counter and queue up resume of a device.
  363. * @dev: Target device.
  364. *
  365. * Bump up the runtime PM usage counter of @dev and queue up a work item to
  366. * carry out runtime-resume of it.
  367. */
  368. static inline int pm_runtime_get(struct device *dev)
  369. {
  370. return __pm_runtime_resume(dev, RPM_GET_PUT | RPM_ASYNC);
  371. }
  372. /**
  373. * pm_runtime_get_sync - Bump up usage counter of a device and resume it.
  374. * @dev: Target device.
  375. *
  376. * Bump up the runtime PM usage counter of @dev and carry out runtime-resume of
  377. * it synchronously.
  378. *
  379. * The possible return values of this function are the same as for
  380. * pm_runtime_resume() and the runtime PM usage counter of @dev remains
  381. * incremented in all cases, even if it returns an error code.
  382. * Consider using pm_runtime_resume_and_get() instead of it, especially
  383. * if its return value is checked by the caller, as this is likely to result
  384. * in cleaner code.
  385. */
  386. static inline int pm_runtime_get_sync(struct device *dev)
  387. {
  388. return __pm_runtime_resume(dev, RPM_GET_PUT);
  389. }
  390. /**
  391. * pm_runtime_resume_and_get - Bump up usage counter of a device and resume it.
  392. * @dev: Target device.
  393. *
  394. * Resume @dev synchronously and if that is successful, increment its runtime
  395. * PM usage counter. Return 0 if the runtime PM usage counter of @dev has been
  396. * incremented or a negative error code otherwise.
  397. */
  398. static inline int pm_runtime_resume_and_get(struct device *dev)
  399. {
  400. int ret;
  401. ret = __pm_runtime_resume(dev, RPM_GET_PUT);
  402. if (ret < 0) {
  403. pm_runtime_put_noidle(dev);
  404. return ret;
  405. }
  406. return 0;
  407. }
  408. /**
  409. * pm_runtime_put - Drop device usage counter and queue up "idle check" if 0.
  410. * @dev: Target device.
  411. *
  412. * Decrement the runtime PM usage counter of @dev and if it turns out to be
  413. * equal to 0, queue up a work item for @dev like in pm_request_idle().
  414. */
  415. static inline int pm_runtime_put(struct device *dev)
  416. {
  417. return __pm_runtime_idle(dev, RPM_GET_PUT | RPM_ASYNC);
  418. }
  419. /**
  420. * pm_runtime_put_autosuspend - Drop device usage counter and queue autosuspend if 0.
  421. * @dev: Target device.
  422. *
  423. * Decrement the runtime PM usage counter of @dev and if it turns out to be
  424. * equal to 0, queue up a work item for @dev like in pm_request_autosuspend().
  425. */
  426. static inline int pm_runtime_put_autosuspend(struct device *dev)
  427. {
  428. return __pm_runtime_suspend(dev,
  429. RPM_GET_PUT | RPM_ASYNC | RPM_AUTO);
  430. }
  431. /**
  432. * pm_runtime_put_sync - Drop device usage counter and run "idle check" if 0.
  433. * @dev: Target device.
  434. *
  435. * Decrement the runtime PM usage counter of @dev and if it turns out to be
  436. * equal to 0, invoke the "idle check" callback of @dev and, depending on its
  437. * return value, set up autosuspend of @dev or suspend it (depending on whether
  438. * or not autosuspend has been enabled for it).
  439. *
  440. * The possible return values of this function are the same as for
  441. * pm_runtime_idle() and the runtime PM usage counter of @dev remains
  442. * decremented in all cases, even if it returns an error code.
  443. */
  444. static inline int pm_runtime_put_sync(struct device *dev)
  445. {
  446. return __pm_runtime_idle(dev, RPM_GET_PUT);
  447. }
  448. /**
  449. * pm_runtime_put_sync_suspend - Drop device usage counter and suspend if 0.
  450. * @dev: Target device.
  451. *
  452. * Decrement the runtime PM usage counter of @dev and if it turns out to be
  453. * equal to 0, carry out runtime-suspend of @dev synchronously.
  454. *
  455. * The possible return values of this function are the same as for
  456. * pm_runtime_suspend() and the runtime PM usage counter of @dev remains
  457. * decremented in all cases, even if it returns an error code.
  458. */
  459. static inline int pm_runtime_put_sync_suspend(struct device *dev)
  460. {
  461. return __pm_runtime_suspend(dev, RPM_GET_PUT);
  462. }
  463. /**
  464. * pm_runtime_put_sync_autosuspend - Drop device usage counter and autosuspend if 0.
  465. * @dev: Target device.
  466. *
  467. * Decrement the runtime PM usage counter of @dev and if it turns out to be
  468. * equal to 0, set up autosuspend of @dev or suspend it synchronously (depending
  469. * on whether or not autosuspend has been enabled for it).
  470. *
  471. * The possible return values of this function are the same as for
  472. * pm_runtime_autosuspend() and the runtime PM usage counter of @dev remains
  473. * decremented in all cases, even if it returns an error code.
  474. */
  475. static inline int pm_runtime_put_sync_autosuspend(struct device *dev)
  476. {
  477. return __pm_runtime_suspend(dev, RPM_GET_PUT | RPM_AUTO);
  478. }
  479. /**
  480. * pm_runtime_set_active - Set runtime PM status to "active".
  481. * @dev: Target device.
  482. *
  483. * Set the runtime PM status of @dev to %RPM_ACTIVE and ensure that dependencies
  484. * of it will be taken into account.
  485. *
  486. * It is not valid to call this function for devices with runtime PM enabled.
  487. */
  488. static inline int pm_runtime_set_active(struct device *dev)
  489. {
  490. return __pm_runtime_set_status(dev, RPM_ACTIVE);
  491. }
  492. /**
  493. * pm_runtime_set_suspended - Set runtime PM status to "suspended".
  494. * @dev: Target device.
  495. *
  496. * Set the runtime PM status of @dev to %RPM_SUSPENDED and ensure that
  497. * dependencies of it will be taken into account.
  498. *
  499. * It is not valid to call this function for devices with runtime PM enabled.
  500. */
  501. static inline int pm_runtime_set_suspended(struct device *dev)
  502. {
  503. return __pm_runtime_set_status(dev, RPM_SUSPENDED);
  504. }
  505. /**
  506. * pm_runtime_disable - Disable runtime PM for a device.
  507. * @dev: Target device.
  508. *
  509. * Prevent the runtime PM framework from working with @dev (by incrementing its
  510. * "blocking" counter).
  511. *
  512. * For each invocation of this function for @dev there must be a matching
  513. * pm_runtime_enable() call in order for runtime PM to be enabled for it.
  514. */
  515. static inline void pm_runtime_disable(struct device *dev)
  516. {
  517. __pm_runtime_disable(dev, true);
  518. }
  519. /**
  520. * pm_runtime_use_autosuspend - Allow autosuspend to be used for a device.
  521. * @dev: Target device.
  522. *
  523. * Allow the runtime PM autosuspend mechanism to be used for @dev whenever
  524. * requested (or "autosuspend" will be handled as direct runtime-suspend for
  525. * it).
  526. *
  527. * NOTE: It's important to undo this with pm_runtime_dont_use_autosuspend()
  528. * at driver exit time unless your driver initially enabled pm_runtime
  529. * with devm_pm_runtime_enable() (which handles it for you).
  530. */
  531. static inline void pm_runtime_use_autosuspend(struct device *dev)
  532. {
  533. __pm_runtime_use_autosuspend(dev, true);
  534. }
  535. /**
  536. * pm_runtime_dont_use_autosuspend - Prevent autosuspend from being used.
  537. * @dev: Target device.
  538. *
  539. * Prevent the runtime PM autosuspend mechanism from being used for @dev which
  540. * means that "autosuspend" will be handled as direct runtime-suspend for it
  541. * going forward.
  542. */
  543. static inline void pm_runtime_dont_use_autosuspend(struct device *dev)
  544. {
  545. __pm_runtime_use_autosuspend(dev, false);
  546. }
  547. #endif