diff mbox series

[v4,07/12] OPP: Add and export helper to get icc path count

Message ID 20200504202243.5476-8-sibis@codeaurora.org
State New
Headers show
Series [v4,01/12] arm64: dts: qcom: sdm845: Add SoC compatible to MTP | expand

Commit Message

Sibi Sankar May 4, 2020, 8:22 p.m. UTC
Add and export 'dev_pm_opp_get_path_count' to get the icc path count
associated with the device.

Signed-off-by: Sibi Sankar <sibis@codeaurora.org>
---
 drivers/opp/core.c     | 20 ++++++++++++++++++++
 include/linux/pm_opp.h |  6 ++++++
 2 files changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/drivers/opp/core.c b/drivers/opp/core.c
index f157e2d768d76..6106146a582d5 100644
--- a/drivers/opp/core.c
+++ b/drivers/opp/core.c
@@ -343,6 +343,26 @@  int dev_pm_opp_get_opp_count(struct device *dev)
 }
 EXPORT_SYMBOL_GPL(dev_pm_opp_get_opp_count);
 
+int dev_pm_opp_get_path_count(struct device *dev)
+{
+	struct opp_table *opp_table;
+	int count;
+
+	opp_table = _find_opp_table(dev);
+	if (IS_ERR(opp_table)) {
+		count = PTR_ERR(opp_table);
+		dev_dbg(dev, "%s: OPP table not found (%d)\n",
+			__func__, count);
+		return count;
+	}
+
+	count = opp_table->path_count;
+	dev_pm_opp_put_opp_table(opp_table);
+
+	return count;
+}
+EXPORT_SYMBOL_GPL(dev_pm_opp_get_path_count);
+
 /**
  * dev_pm_opp_find_freq_exact() - search for an exact frequency
  * @dev:		device for which we do this operation
diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h
index 87ba295080a2b..ffd075c8da0ca 100644
--- a/include/linux/pm_opp.h
+++ b/include/linux/pm_opp.h
@@ -101,6 +101,7 @@  unsigned int dev_pm_opp_get_level(struct dev_pm_opp *opp);
 bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp);
 
 int dev_pm_opp_get_opp_count(struct device *dev);
+int dev_pm_opp_get_path_count(struct device *dev);
 unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev);
 unsigned long dev_pm_opp_get_max_volt_latency(struct device *dev);
 unsigned long dev_pm_opp_get_max_transition_latency(struct device *dev);
@@ -197,6 +198,11 @@  static inline int dev_pm_opp_get_opp_count(struct device *dev)
 	return 0;
 }
 
+static inline int dev_pm_opp_get_path_count(struct device *dev)
+{
+	return 0;
+}
+
 static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev)
 {
 	return 0;