diff mbox series

[v2,1/4] opp: Add more resource-managed variants of dev_pm_opp_of_add_table()

Message ID 20210920172249.28206-2-digetx@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series Make probe() of Tegra devfreq driver completely resource-managed | expand

Commit Message

Dmitry Osipenko Sept. 20, 2021, 5:22 p.m. UTC
Add resource-managed variants of dev_pm_opp_of_add_table_indexed() and
dev_pm_opp_of_add_table_noclk(), allowing drivers to remove boilerplate
code.

Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
---
 drivers/opp/of.c       | 46 +++++++++++++++++++++++++++++++++++-------
 include/linux/pm_opp.h | 12 +++++++++++
 2 files changed, 51 insertions(+), 7 deletions(-)

Comments

Viresh Kumar Oct. 4, 2021, 11:04 a.m. UTC | #1
On 20-09-21, 20:22, Dmitry Osipenko wrote:
> Add resource-managed variants of dev_pm_opp_of_add_table_indexed() and
> dev_pm_opp_of_add_table_noclk(), allowing drivers to remove boilerplate
> code.
> 
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
>  drivers/opp/of.c       | 46 +++++++++++++++++++++++++++++++++++-------
>  include/linux/pm_opp.h | 12 +++++++++++
>  2 files changed, 51 insertions(+), 7 deletions(-)
> 
> diff --git a/drivers/opp/of.c b/drivers/opp/of.c
> index 2a97c6535c4c..bd01ecb1d85c 100644
> --- a/drivers/opp/of.c
> +++ b/drivers/opp/of.c
> @@ -1081,6 +1081,17 @@ static void devm_pm_opp_of_table_release(void *data)
>  	dev_pm_opp_of_remove_table(data);
>  }
>  
> +static int devm_of_add_table_indexed(struct device *dev, int index, bool getclk)

Made this _devm_of_add_table_indexed() and applied this patch. Thanks.

What about rest of the series ?
Dmitry Osipenko Oct. 4, 2021, 2:52 p.m. UTC | #2
04.10.2021 14:04, Viresh Kumar пишет:
> On 20-09-21, 20:22, Dmitry Osipenko wrote:
>> Add resource-managed variants of dev_pm_opp_of_add_table_indexed() and
>> dev_pm_opp_of_add_table_noclk(), allowing drivers to remove boilerplate
>> code.
>>
>> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
>> ---
>>  drivers/opp/of.c       | 46 +++++++++++++++++++++++++++++++++++-------
>>  include/linux/pm_opp.h | 12 +++++++++++
>>  2 files changed, 51 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/opp/of.c b/drivers/opp/of.c
>> index 2a97c6535c4c..bd01ecb1d85c 100644
>> --- a/drivers/opp/of.c
>> +++ b/drivers/opp/of.c
>> @@ -1081,6 +1081,17 @@ static void devm_pm_opp_of_table_release(void *data)
>>  	dev_pm_opp_of_remove_table(data);
>>  }
>>  
>> +static int devm_of_add_table_indexed(struct device *dev, int index, bool getclk)
> 
> Made this _devm_of_add_table_indexed() and applied this patch. Thanks.
> 
> What about rest of the series ?
> 

I assume you should take it all via the OPP tree since Chanwoo gave the
acks, otherwise immutable branch is needed from you.
diff mbox series

Patch

diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index 2a97c6535c4c..bd01ecb1d85c 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -1081,6 +1081,17 @@  static void devm_pm_opp_of_table_release(void *data)
 	dev_pm_opp_of_remove_table(data);
 }
 
+static int devm_of_add_table_indexed(struct device *dev, int index, bool getclk)
+{
+	int ret;
+
+	ret = _of_add_table_indexed(dev, index, getclk);
+	if (ret)
+		return ret;
+
+	return devm_add_action_or_reset(dev, devm_pm_opp_of_table_release, dev);
+}
+
 /**
  * devm_pm_opp_of_add_table() - Initialize opp table from device tree
  * @dev:	device pointer used to lookup OPP table.
@@ -1102,13 +1113,7 @@  static void devm_pm_opp_of_table_release(void *data)
  */
 int devm_pm_opp_of_add_table(struct device *dev)
 {
-	int ret;
-
-	ret = dev_pm_opp_of_add_table(dev);
-	if (ret)
-		return ret;
-
-	return devm_add_action_or_reset(dev, devm_pm_opp_of_table_release, dev);
+	return devm_of_add_table_indexed(dev, 0, true);
 }
 EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table);
 
@@ -1151,6 +1156,19 @@  int dev_pm_opp_of_add_table_indexed(struct device *dev, int index)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_indexed);
 
+/**
+ * devm_pm_opp_of_add_table_indexed() - Initialize indexed opp table from device tree
+ * @dev:	device pointer used to lookup OPP table.
+ * @index:	Index number.
+ *
+ * This is a resource-managed variant of dev_pm_opp_of_add_table_indexed().
+ */
+int devm_pm_opp_of_add_table_indexed(struct device *dev, int index)
+{
+	return devm_of_add_table_indexed(dev, index, true);
+}
+EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table_indexed);
+
 /**
  * dev_pm_opp_of_add_table_noclk() - Initialize indexed opp table from device
  *		tree without getting clk for device.
@@ -1169,6 +1187,20 @@  int dev_pm_opp_of_add_table_noclk(struct device *dev, int index)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_of_add_table_noclk);
 
+/**
+ * devm_pm_opp_of_add_table_noclk() - Initialize indexed opp table from device
+ *		tree without getting clk for device.
+ * @dev:	device pointer used to lookup OPP table.
+ * @index:	Index number.
+ *
+ * This is a resource-managed variant of dev_pm_opp_of_add_table_noclk().
+ */
+int devm_pm_opp_of_add_table_noclk(struct device *dev, int index)
+{
+	return devm_of_add_table_indexed(dev, index, false);
+}
+EXPORT_SYMBOL_GPL(devm_pm_opp_of_add_table_noclk);
+
 /* CPU device specific helpers */
 
 /**
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 84150a22fd7c..a95d6fdd20b6 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -439,7 +439,9 @@  static inline int dev_pm_opp_sync_regulators(struct device *dev)
 #if defined(CONFIG_PM_OPP) && defined(CONFIG_OF)
 int dev_pm_opp_of_add_table(struct device *dev);
 int dev_pm_opp_of_add_table_indexed(struct device *dev, int index);
+int devm_pm_opp_of_add_table_indexed(struct device *dev, int index);
 int dev_pm_opp_of_add_table_noclk(struct device *dev, int index);
+int devm_pm_opp_of_add_table_noclk(struct device *dev, int index);
 void dev_pm_opp_of_remove_table(struct device *dev);
 int devm_pm_opp_of_add_table(struct device *dev);
 int dev_pm_opp_of_cpumask_add_table(const struct cpumask *cpumask);
@@ -465,11 +467,21 @@  static inline int dev_pm_opp_of_add_table_indexed(struct device *dev, int index)
 	return -EOPNOTSUPP;
 }
 
+static inline int devm_pm_opp_of_add_table_indexed(struct device *dev, int index)
+{
+	return -EOPNOTSUPP;
+}
+
 static inline int dev_pm_opp_of_add_table_noclk(struct device *dev, int index)
 {
 	return -EOPNOTSUPP;
 }
 
+static inline int devm_pm_opp_of_add_table_noclk(struct device *dev, int index)
+{
+	return -EOPNOTSUPP;
+}
+
 static inline void dev_pm_opp_of_remove_table(struct device *dev)
 {
 }