Skip to contentSkip to conversation

PM / devfreq: Use freq_table for available_frequencies

PATCH Superseded Saravana Kannan 1 participant 2 messages Apr 11, 2014 – Apr 14, 2014

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PM / devfreq: Use freq_table for available_frequencies

Some devices use freq_table instead of OPP. For those devices, the available_frequencies file shows up empty. Fix that by using freq_table to generate the available_frequencies data when OPP is not present.

---
 drivers/devfreq/devfreq.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
drivers/devfreq/devfreq.c +11 -4
index 2042ec3..a715d15 100644
@@ -912,19 +912,26 @@ static ssize_t available_frequencies_show(struct device *d,
 	struct devfreq *df = to_devfreq(d);
 	struct device *dev = df->dev.parent;
 	struct dev_pm_opp *opp;
+	unsigned int i = 0, max_state = df->profile->max_state;
+	bool use_opp;
 	ssize_t count = 0;
 	unsigned long freq = 0;
 
 	rcu_read_lock();
+	use_opp = dev_pm_opp_get_opp_count(dev) > 0;
 	do {
-		opp = dev_pm_opp_find_freq_ceil(dev, &freq);
-		if (IS_ERR(opp))
-			break;
+		if (use_opp) {
+			opp = dev_pm_opp_find_freq_ceil(dev, &freq);
+			if (IS_ERR(opp))
+				break;
+		} else {
+			freq = df->profile->freq_table[i++];
+		}
 
 		count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
 				   "%lu ", freq);
 		freq++;
-	} while (1);
+	} while (use_opp || (!use_opp && i < max_state));
 	rcu_read_unlock();
 
 	/* Truncate the trailing space */
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation
#1 lore raw

MyungJoo/Kyungmin,

Bump. Can we accept this patch please?

-Saravana

Quoted 45 lines · Saravana Kannan

Some devices use freq_table instead of OPP. For those devices, the available_frequencies file shows up empty. Fix that by using freq_table to generate the available_frequencies data when OPP is not present.

---
  drivers/devfreq/devfreq.c | 15 +++++++++++----
  1 file changed, 11 insertions(+), 4 deletions(-)
drivers/devfreq/devfreq.c +11 -4
index 2042ec3..a715d15 100644
@@ -912,19 +912,26 @@ static ssize_t available_frequencies_show(struct device *d,
  	struct devfreq *df = to_devfreq(d);
  	struct device *dev = df->dev.parent;
  	struct dev_pm_opp *opp;
+	unsigned int i = 0, max_state = df->profile->max_state;
+	bool use_opp;
  	ssize_t count = 0;
  	unsigned long freq = 0;
 
  	rcu_read_lock();
+	use_opp = dev_pm_opp_get_opp_count(dev) > 0;
  	do {
-		opp = dev_pm_opp_find_freq_ceil(dev, &freq);
-		if (IS_ERR(opp))
-			break;
+		if (use_opp) {
+			opp = dev_pm_opp_find_freq_ceil(dev, &freq);
+			if (IS_ERR(opp))
+				break;
+		} else {
+			freq = df->profile->freq_table[i++];
+		}
 
  		count += scnprintf(&buf[count], (PAGE_SIZE - count - 2),
  				   "%lu ", freq);
  		freq++;
-	} while (1);
+	} while (use_opp || (!use_opp && i < max_state));
  	rcu_read_unlock();
 
  	/* Truncate the trailing space */
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
hosted by The Linux Foundation