lkml.org 
[lkml]   [2021]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v1 2/4] PM / devfreq: Add devm_devfreq_add_governor()
Date
Add resource-managed variant of devfreq_add_governor().

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
drivers/devfreq/devfreq.c | 26 ++++++++++++++++++++++++++
drivers/devfreq/governor.h | 3 +++
2 files changed, 29 insertions(+)

diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c
index 85faa7a5c7d1..d3af000ec290 100644
--- a/drivers/devfreq/devfreq.c
+++ b/drivers/devfreq/devfreq.c
@@ -1301,6 +1301,32 @@ int devfreq_add_governor(struct devfreq_governor *governor)
}
EXPORT_SYMBOL(devfreq_add_governor);

+static void devm_devfreq_remove_governor(void *governor)
+{
+ 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
diff --git a/drivers/devfreq/governor.h b/drivers/devfreq/governor.h
index 2d69a0ce6291..0d70a9ad951e 100644
--- a/drivers/devfreq/governor.h
+++ b/drivers/devfreq/governor.h
@@ -94,4 +94,7 @@ static inline int devfreq_update_stats(struct devfreq *df)

return df->profile->get_dev_status(df->dev.parent, &df->last_status);
}
+
+int devm_devfreq_add_governor(struct device *dev,
+ struct devfreq_governor *governor);
#endif /* _GOVERNOR_H */
--
2.32.0
\
 
 \ /
  Last update: 2021-09-12 20:46    [W:0.108 / U:4.248 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site