From patchwork Tue Apr 15 19:29:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Saravana Kannan X-Patchwork-Id: 3995301 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 65866BFF02 for ; Tue, 15 Apr 2014 19:33:37 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 8A79B201FE for ; Tue, 15 Apr 2014 19:33:36 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id BAA5C201FA for ; Tue, 15 Apr 2014 19:33:35 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wa93z-0004LZ-2F; Tue, 15 Apr 2014 19:30:35 +0000 Received: from smtp.codeaurora.org ([198.145.11.231]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Wa93q-00047d-Q1 for linux-arm-kernel@lists.infradead.org; Tue, 15 Apr 2014 19:30:27 +0000 Received: from smtp.codeaurora.org (localhost [127.0.0.1]) by smtp.codeaurora.org (Postfix) with ESMTP id 0E24A13EEFC; Tue, 15 Apr 2014 19:30:06 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 486) id F3A6613F003; Tue, 15 Apr 2014 19:30:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from skannan1-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: skannan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 7A29F13EEFC; Tue, 15 Apr 2014 19:30:05 +0000 (UTC) From: Saravana Kannan To: MyungJoo Ham , Kyungmin Park 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> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1368716.232331397543409452.JavaMail.weblogic@epv6ml06> References: <1368716.232331397543409452.JavaMail.weblogic@epv6ml06> X-Virus-Scanned: ClamAV using ClamSMTP X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140415_123026_864976_72A424BC X-CRM114-Status: GOOD ( 17.54 ) X-Spam-Score: -0.7 (/) Cc: linux-arm-msm@vger.kernel.org, Saravana Kannan , linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pm@vger.kernel.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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)