diff options
author | Dmitry Osipenko <digetx@gmail.com> | 2021-09-20 20:22:47 +0300 |
---|---|---|
committer | Viresh Kumar <viresh.kumar@linaro.org> | 2021-10-05 07:24:38 +0300 |
commit | 1cc55204b0dbba0ca09cc14624cbbeeb2d35742f (patch) | |
tree | 6e05d41a6cb18329fba90db12376c7cc99582aa6 /drivers/devfreq/devfreq.c | |
parent | e69709f6861aaba80b4eaab6825e8c522a2afb5c (diff) | |
download | linux-1cc55204b0dbba0ca09cc14624cbbeeb2d35742f.tar.xz |
PM / devfreq: Add devm_devfreq_add_governor()
Add resource-managed variant of devfreq_add_governor().
Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
Acked-by: Chanwoo Choi <cw00.choi@samsung.com>
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/devfreq/devfreq.c')
-rw-r--r-- | drivers/devfreq/devfreq.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 85faa7a5c7d1..4579eefb8fe7 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -1301,6 +1301,32 @@ err_out: } EXPORT_SYMBOL(devfreq_add_governor); +static void devm_devfreq_remove_governor(void *governor) +{ + WARN_ON(devfreq_remove_governor(governor)); +} + +/** + * devm_devfreq_add_governor() - Add devfreq governor + * @dev: device which adds devfreq governor + * @governor: the devfreq governor to be added + * + * This is a resource-managed variant of devfreq_add_governor(). + */ +int devm_devfreq_add_governor(struct device *dev, + struct devfreq_governor *governor) +{ + int err; + + err = devfreq_add_governor(governor); + if (err) + return err; + + return devm_add_action_or_reset(dev, devm_devfreq_remove_governor, + governor); +} +EXPORT_SYMBOL(devm_devfreq_add_governor); + /** * devfreq_remove_governor() - Remove devfreq feature from a device. * @governor: the devfreq governor to be removed |