diff mbox series

[1/2] OPP: Add helper to retrieve the OF node for an OPP table

Message ID 20240902224815.78220-2-ulf.hansson@linaro.org (mailing list archive)
State Handled Elsewhere, archived
Headers show
Series OPP/pmdomain: Assign the correct required-dev | expand

Commit Message

Ulf Hansson Sept. 2, 2024, 10:48 p.m. UTC
As being shown from a subsequent change it can be useful for a OPP consumer
to retrieve the corresponding OF node for an OPP table. Therefore, let's
add an OPP helper for it.

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
---
 drivers/opp/of.c       | 12 ++++++++++++
 include/linux/pm_opp.h |  6 ++++++
 2 files changed, 18 insertions(+)
diff mbox series

Patch

diff --git a/drivers/opp/of.c b/drivers/opp/of.c
index fd5ed2858258..f0950339da55 100644
--- a/drivers/opp/of.c
+++ b/drivers/opp/of.c
@@ -1461,6 +1461,18 @@  struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_get_of_node);
 
+/**
+ * dev_pm_opp_table_to_of_node() - Finds the node for an OPP table
+ * @opp_table:	The opp_table to return the node for
+ *
+ * Return: The DT node corresponding to the @opp_table.
+ */
+struct device_node *dev_pm_opp_table_to_of_node(struct opp_table *opp_table)
+{
+	return opp_table->np;
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_table_to_of_node);
+
 /*
  * Callback function provided to the Energy Model framework upon registration.
  * It provides the power used by @dev at @kHz if it is the frequency of an
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 451a7465a605..7894e631cded 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -469,6 +469,7 @@  void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask);
 int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask);
 struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev);
 struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp);
+struct device_node *dev_pm_opp_table_to_of_node(struct opp_table *table);
 int of_get_required_opp_performance_state(struct device_node *np, int index);
 bool dev_pm_opp_of_has_required_opp(struct device *dev);
 int dev_pm_opp_of_find_icc_paths(struct device *dev, struct opp_table *opp_table);
@@ -528,6 +529,11 @@  static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp)
 	return NULL;
 }
 
+static inline struct device_node *dev_pm_opp_table_to_of_node(struct opp_table *table)
+{
+	return NULL;
+}
+
 static inline int dev_pm_opp_of_register_em(struct device *dev,
 					    struct cpumask *cpus)
 {