Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

PM: runtime: add devm_pm_runtime_enable helper

A typical code pattern for pm_runtime_enable() call is to call it in the
_probe function and to call pm_runtime_disable() both from _probe error
path and from _remove function. For some drivers the whole remove
function would consist of the call to pm_remove_disable().

Add helper function to replace this bolierplate piece of code. Calling
devm_pm_runtime_enable() removes the need for calling
pm_runtime_disable() both in the probe()'s error path and in the
remove() function.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20210731195034.979084-2-dmitry.baryshkov@linaro.org
Acked-by: Rafael J. Wysocki <rafael@kernel.org>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>

authored by

Dmitry Baryshkov and committed by
Stephen Boyd
b3636a3a 5d9bc010

+21
+17
drivers/base/power/runtime.c
··· 1447 1447 } 1448 1448 EXPORT_SYMBOL_GPL(pm_runtime_enable); 1449 1449 1450 + static void pm_runtime_disable_action(void *data) 1451 + { 1452 + pm_runtime_disable(data); 1453 + } 1454 + 1455 + /** 1456 + * devm_pm_runtime_enable - devres-enabled version of pm_runtime_enable. 1457 + * @dev: Device to handle. 1458 + */ 1459 + int devm_pm_runtime_enable(struct device *dev) 1460 + { 1461 + pm_runtime_enable(dev); 1462 + 1463 + return devm_add_action_or_reset(dev, pm_runtime_disable_action, dev); 1464 + } 1465 + EXPORT_SYMBOL_GPL(devm_pm_runtime_enable); 1466 + 1450 1467 /** 1451 1468 * pm_runtime_forbid - Block runtime PM of a device. 1452 1469 * @dev: Device to handle.
+4
include/linux/pm_runtime.h
··· 59 59 extern void pm_runtime_new_link(struct device *dev); 60 60 extern void pm_runtime_drop_link(struct device_link *link); 61 61 62 + extern int devm_pm_runtime_enable(struct device *dev); 63 + 62 64 /** 63 65 * pm_runtime_get_if_in_use - Conditionally bump up runtime PM usage counter. 64 66 * @dev: Target device. ··· 254 252 static inline void __pm_runtime_disable(struct device *dev, bool c) {} 255 253 static inline void pm_runtime_allow(struct device *dev) {} 256 254 static inline void pm_runtime_forbid(struct device *dev) {} 255 + 256 + static inline int devm_pm_runtime_enable(struct device *dev) { return 0; } 257 257 258 258 static inline void pm_suspend_ignore_children(struct device *dev, bool enable) {} 259 259 static inline void pm_runtime_get_noresume(struct device *dev) {}