From mboxrd@z Thu Jan 1 00:00:00 1970 From: Saravana Kannan Subject: [PATCH v2] PM / devfreq: Use freq_table for available_frequencies Date: Tue, 15 Apr 2014 12:29:58 -0700 Message-ID: <1397590198-4965-1-git-send-email-skannan@codeaurora.org> References: <1368716.232331397543409452.JavaMail.weblogic@epv6ml06> Return-path: Received: from smtp.codeaurora.org ([198.145.11.231]:48888 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751111AbaDOTaG (ORCPT ); Tue, 15 Apr 2014 15:30:06 -0400 In-Reply-To: <1368716.232331397543409452.JavaMail.weblogic@epv6ml06> Sender: linux-arm-msm-owner@vger.kernel.org List-Id: linux-arm-msm@vger.kernel.org To: MyungJoo Ham , Kyungmin Park Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, 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 it's available. OPP find frequency APIs also skips frequencies that have been temporarily disabled (say, due to thermal, etc). Since available_frequencies is supposed to show the entire list of available frequencies without taking temporary limits into consideration, preference is given to freq_table when available. Signed-off-by: Saravana Kannan --- drivers/devfreq/devfreq.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 2042ec3..527cbe2 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -912,20 +912,27 @@ 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; ssize_t count = 0; unsigned long freq = 0; - rcu_read_lock(); - do { - opp = dev_pm_opp_find_freq_ceil(dev, &freq); - if (IS_ERR(opp)) - break; - - count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), - "%lu ", freq); - freq++; - } while (1); - rcu_read_unlock(); + if (df->profile->freq_table) { + for (i = 0; i < df->profile->max_state; i++) + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%u ", df->profile->freq_table[i]); + } else { + rcu_read_lock(); + do { + opp = dev_pm_opp_find_freq_ceil(dev, &freq); + if (IS_ERR(opp)) + break; + + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%lu ", freq); + freq++; + } while (1); + rcu_read_unlock(); + } /* Truncate the trailing space */ if (count) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation From mboxrd@z Thu Jan 1 00:00:00 1970 From: skannan@codeaurora.org (Saravana Kannan) Date: Tue, 15 Apr 2014 12:29:58 -0700 Subject: [PATCH v2] PM / devfreq: Use freq_table for available_frequencies In-Reply-To: <1368716.232331397543409452.JavaMail.weblogic@epv6ml06> References: <1368716.232331397543409452.JavaMail.weblogic@epv6ml06> Message-ID: <1397590198-4965-1-git-send-email-skannan@codeaurora.org> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org 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 it's available. OPP find frequency APIs also skips frequencies that have been temporarily disabled (say, due to thermal, etc). Since available_frequencies is supposed to show the entire list of available frequencies without taking temporary limits into consideration, preference is given to freq_table when available. Signed-off-by: Saravana Kannan --- drivers/devfreq/devfreq.c | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 2042ec3..527cbe2 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -912,20 +912,27 @@ 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; ssize_t count = 0; unsigned long freq = 0; - rcu_read_lock(); - do { - opp = dev_pm_opp_find_freq_ceil(dev, &freq); - if (IS_ERR(opp)) - break; - - count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), - "%lu ", freq); - freq++; - } while (1); - rcu_read_unlock(); + if (df->profile->freq_table) { + for (i = 0; i < df->profile->max_state; i++) + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%u ", df->profile->freq_table[i]); + } else { + rcu_read_lock(); + do { + opp = dev_pm_opp_find_freq_ceil(dev, &freq); + if (IS_ERR(opp)) + break; + + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%lu ", freq); + freq++; + } while (1); + rcu_read_unlock(); + } /* Truncate the trailing space */ if (count) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation