diff mbox series

[RFC,v3,07/10] opp: Remove multiple attached opp tables from a device

Message ID 20200127200350.24465-8-sibis@codeaurora.org (mailing list archive)
State New, archived
Headers show
Series DDR/L3 Scaling support on SDM845 and SC7180 SoCs | expand

Commit Message

Sibi Sankar Jan. 27, 2020, 8:03 p.m. UTC
Introduce _dev_pm_opp_find_and_remove_table_indexed to remove
all the linked opp tables from a device.

Signed-off-by: Sibi Sankar <sibis@codeaurora.org>
---
 drivers/opp/core.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index e9d633c9e40b1..cc2f156db7fda 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -2632,12 +2632,13 @@  int dev_pm_opp_unregister_notifier(struct device *dev,
 }
 EXPORT_SYMBOL(dev_pm_opp_unregister_notifier);
 
-void _dev_pm_opp_find_and_remove_table(struct device *dev)
+static void _dev_pm_opp_find_and_remove_table_indexed(struct device *dev,
+						      int index)
 {
 	struct opp_table *opp_table;
 
 	/* Check for existing table for 'dev' */
-	opp_table = _find_opp_table_indexed(dev, 0);
+	opp_table = _find_opp_table_indexed(dev, index);
 	if (IS_ERR(opp_table)) {
 		int error = PTR_ERR(opp_table);
 
@@ -2658,6 +2659,18 @@  void _dev_pm_opp_find_and_remove_table(struct device *dev)
 	dev_pm_opp_put_opp_table(opp_table);
 }
 
+void _dev_pm_opp_find_and_remove_table(struct device *dev)
+{
+	int count, i;
+
+	count = of_count_phandle_with_args(dev->of_node,
+					   "operating-points-v2", NULL);
+	count = max(count, 1);
+
+	for (i = 0; i < count; i++)
+		_dev_pm_opp_find_and_remove_table_indexed(dev, i);
+}
+
 /**
  * dev_pm_opp_remove_table() - Free all OPPs associated with the device
  * @dev:	device pointer used to lookup OPP table.