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_clk_create helper

A typical code pattern for pm_clk_create() call is to call it in the
_probe function and to call pm_clk_destroy() 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_clk_create() removes the need for calling pm_clk_destroy() 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-3-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
a649136b b3636a3a

+22
+17
drivers/base/power/clock_ops.c
··· 519 519 } 520 520 EXPORT_SYMBOL_GPL(pm_clk_destroy); 521 521 522 + static void pm_clk_destroy_action(void *data) 523 + { 524 + pm_clk_destroy(data); 525 + } 526 + 527 + int devm_pm_clk_create(struct device *dev) 528 + { 529 + int ret; 530 + 531 + ret = pm_clk_create(dev); 532 + if (ret) 533 + return ret; 534 + 535 + return devm_add_action_or_reset(dev, pm_clk_destroy_action, dev); 536 + } 537 + EXPORT_SYMBOL_GPL(devm_pm_clk_create); 538 + 522 539 /** 523 540 * pm_clk_suspend - Disable clocks in a device's PM clock list. 524 541 * @dev: Device to disable the clocks for.
+5
include/linux/pm_clock.h
··· 47 47 extern void pm_clk_remove_clk(struct device *dev, struct clk *clk); 48 48 extern int pm_clk_suspend(struct device *dev); 49 49 extern int pm_clk_resume(struct device *dev); 50 + extern int devm_pm_clk_create(struct device *dev); 50 51 #else 51 52 static inline bool pm_clk_no_clocks(struct device *dev) 52 53 { ··· 83 82 #define pm_clk_resume NULL 84 83 static inline void pm_clk_remove_clk(struct device *dev, struct clk *clk) 85 84 { 85 + } 86 + static inline int devm_pm_clk_create(struct device *dev) 87 + { 88 + return -EINVAL; 86 89 } 87 90 #endif 88 91