Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752220AbdIUAeK (ORCPT ); Wed, 20 Sep 2017 20:34:10 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:55654 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751937AbdIUAd6 (ORCPT ); Wed, 20 Sep 2017 20:33:58 -0400 X-AuditID: b6c32a35-f798c6d000005940-ca-59c308f4ca5b From: Chanwoo Choi To: myungjoo.ham@samsung.com, kyungmin.park@samsung.com, cw00.choi@samsung.com Cc: rafael.j.wysocki@intel.com, chanwoo@kernel.org, inki.dae@samsung.com, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 4/8] PM / devfreq: Show the all available frequencies Date: Thu, 21 Sep 2017 09:33:48 +0900 Message-id: <1505954032-3327-5-git-send-email-cw00.choi@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1505954032-3327-1-git-send-email-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrEKsWRmVeSWpSXmKPExsWy7bCmnu4XjsORBo+nyFpMvHGFxeL6l+es FpPuT2CxONv0ht3i8q45bBafe48wWtxuXMFm8XjFW3YHDo/Fe14yeWxa1cnm0bdlFaPH501y ASxRqTYZqYkpqUUKqXnJ+SmZeem2St7B8c7xpmYGhrqGlhbmSgp5ibmptkouPgG6bpk5QGco KZQl5pQChQISi4uV9O1sivJLS1IVMvKLS2yVog0NjfQMDcz1jIyM9EyMY62MTIFKElIz9p6K KtgjUNG+8CBTA+Mq3i5GTg4JAROJjze6GCFsMYkL99azdTFycQgJ7GCUePrnKDOE851R4tXZ PaxdjBxgHZ+u8EHEdzNKnHjzlwmkW0jgB6PEpQ2BIDabgJbE/hc32EBsEYEAic61q8BqmAWa GCWmLnMAsYUFPCS2PpvBBDKTRUBVYtHuYJAwr4CLRPvqlewQB8lJfNjzCMzmFHCV+Ha2C+w4 CYEJbBLt5zZ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HPUnrs32+u/tsb05HRkCXqcOu+ h3ZPz9zv07+d5I3tucXsH/zIw0792Zbwquacpoarj464/1zBn5VnqxO66dWGf52avSY9CUEV fyf/dbg52/Ws/RsZ3bXOTr8OnhffXnDmxVOtX54fn8gGBNTXnbEJMjqnxFKckWioxVxUnAgA 8V0BLB0CAAA= X-CMS-MailID: 20170921003356epcas1p4c6e4da1fab6f56468ecca9e5889faa43 X-Msg-Generator: CA X-Sender-IP: 182.195.42.142 X-Local-Sender: =?UTF-8?B?7LWc7LCs7JqwG1RpemVuIFBsYXRmb3JtIExhYihTL1fshLw=?= =?UTF-8?B?7YSwKRvsgrzshLHsoITsnpAbU2VuaW9yIEVuZ2luZWVy?= X-Global-Sender: =?UTF-8?B?Q2hhbndvbyBDaG9pG1RpemVuIFBsYXRmb3JtIExhYi4bU2Ft?= =?UTF-8?B?c3VuZyBFbGVjdHJvbmljcxtTZW5pb3IgRW5naW5lZXI=?= X-Sender-Code: =?UTF-8?B?QzEwG1RFTEUbQzEwVjgxMTE=?= CMS-TYPE: 101P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20170921003356epcas1p4c6e4da1fab6f56468ecca9e5889faa43 X-RootMTR: 20170921003356epcas1p4c6e4da1fab6f56468ecca9e5889faa43 References: <1505954032-3327-1-git-send-email-cw00.choi@samsung.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2044 Lines: 62 The commit a76caf55e5b35 ("thermal: Add devfreq cooling") allows the devfreq device to use the cooling device. When the cooling down are required, the devfreq_cooling.c disables the OPP entry with the dev_pm_opp_disable(). In result, 'available_frequencies'[1] sysfs node never came to show the all available frequencies. [1] /sys/class/devfreq/.../available_frequencies So, this patch uses the 'freq_table' in the 'struct devfreq_dev_profile' in order to show the all available frequencies. - If 'freq_table' is NULL, devfreq core initializes them by using OPP values. - If 'freq_table' is initialized, devfreq core just uses the 'freq_table'. Signed-off-by: Chanwoo Choi --- drivers/devfreq/devfreq.c | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index 799a0cf75d39..1c4b377cacfb 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -1185,22 +1185,26 @@ static ssize_t available_frequencies_show(struct device *d, char *buf) { struct devfreq *df = to_devfreq(d); - struct device *dev = df->dev.parent; - struct dev_pm_opp *opp; ssize_t count = 0; - unsigned long freq = 0; + unsigned long *freq_table; + int i, max_state; - do { - opp = dev_pm_opp_find_freq_ceil(dev, &freq); - if (IS_ERR(opp)) - break; + mutex_lock(&df->lock); - dev_pm_opp_put(opp); - count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), - "%lu ", freq); - freq++; - } while (1); + freq_table = df->profile->freq_table; + max_state = df->profile->max_state; + if (freq_table[0] < freq_table[max_state - 1]) { + for (i = 0; i < max_state; i++) + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%lu ", freq_table[i]); + } else { + for (i = max_state - 1; i >= 0 ; i--) + count += scnprintf(&buf[count], (PAGE_SIZE - count - 2), + "%lu ", freq_table[i]); + } + + mutex_unlock(&df->lock); /* Truncate the trailing space */ if (count) count--; -- 1.9.1