summaryrefslogtreecommitdiffstats
path: root/drivers/opp
diff options
context:
space:
mode:
authorYangtao Li <tiny.windzz@gmail.com>2021-03-14 17:33:55 +0100
committerViresh Kumar <viresh.kumar@linaro.org>2021-03-15 04:56:53 +0100
commit32aee78bc5184c7a51a081939721e97cfad4a44e (patch)
treeb795d1917f4d18241e3f3e2d59448a7e097a97aa /drivers/opp
parentopp: Add devres wrapper for dev_pm_opp_set_clkname (diff)
downloadlinux-32aee78bc5184c7a51a081939721e97cfad4a44e.tar.xz
linux-32aee78bc5184c7a51a081939721e97cfad4a44e.zip
opp: Add devres wrapper for dev_pm_opp_set_regulators
Add devres wrapper for dev_pm_opp_set_regulators() to simplify drivers code. Signed-off-by: Yangtao Li <tiny.windzz@gmail.com> Signed-off-by: Dmitry Osipenko <digetx@gmail.com> Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Diffstat (limited to 'drivers/opp')
-rw-r--r--drivers/opp/core.c30
1 files changed, 30 insertions, 0 deletions
diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index 61c48b2d4679..d77ec2c55783 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -2047,6 +2047,36 @@ put_opp_table:
}
EXPORT_SYMBOL_GPL(dev_pm_opp_put_regulators);
+static void devm_pm_opp_regulators_release(void *data)
+{
+ dev_pm_opp_put_regulators(data);
+}
+
+/**
+ * devm_pm_opp_set_regulators() - Set regulator names for the device
+ * @dev: Device for which regulator name is being set.
+ * @names: Array of pointers to the names of the regulator.
+ * @count: Number of regulators.
+ *
+ * This is a resource-managed variant of dev_pm_opp_set_regulators().
+ *
+ * Return: 0 on success and errorno otherwise.
+ */
+int devm_pm_opp_set_regulators(struct device *dev,
+ const char * const names[],
+ unsigned int count)
+{
+ struct opp_table *opp_table;
+
+ opp_table = dev_pm_opp_set_regulators(dev, names, count);
+ if (IS_ERR(opp_table))
+ return PTR_ERR(opp_table);
+
+ return devm_add_action_or_reset(dev, devm_pm_opp_regulators_release,
+ opp_table);
+}
+EXPORT_SYMBOL_GPL(devm_pm_opp_set_regulators);
+
/**
* dev_pm_opp_set_clkname() - Set clk name for the device
* @dev: Device for which clk name is being set.