Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751825AbdHXBoo (ORCPT ); Wed, 23 Aug 2017 21:44:44 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:29206 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751146AbdHXBnC (ORCPT ); Wed, 23 Aug 2017 21:43:02 -0400 X-AuditID: b6c32a35-f798c6d000005940-70-599e2f2418cd 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-kernel@vger.kernel.org, linux-pm@vger.kernel.org Subject: [PATCH 08/12] PM / devfreq: Show the available min/max frequency through sysfs node Date: Thu, 24 Aug 2017 10:42:55 +0900 Message-id: <1503538979-22693-9-git-send-email-cw00.choi@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1503538979-22693-1-git-send-email-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrCKsWRmVeSWpSXmKPExsWy7bCmrq6K/rxIg87rYhYTb1xhsbj+5Tmr xaT7E1gszja9Ybe4vGsOm8Xn3iOMFrcbV7BZPF7xlt2Bw2PxnpdMHptWdbJ59G1ZxejxeZNc AEtUqk1GamJKapFCal5yfkpmXrqtkndwvHO8qZmBoa6hpYW5kkJeYm6qrZKLT4CuW2YO0BlK CmWJOaVAoYDE4mIlfTubovzSklSFjPziElulaENDIz1DA3M9IyMjPRPjWCsjU6CShNSMhtfn WQt+8FccP5HVwLiTt4uRg0NCwETizUWmLkZOIFNM4sK99WxdjFwcQgI7GCXW3rzEDuF8Z5S4 f/AsI0SVicTH5zOYIBIbGCU+Xj4N1fKDUeLEhE1gVWwCWhL7X9xgA7FFBAIkOteuAutgFmhi lNh/7wY7SEJYIE5iz5YrYDaLgKrExIU7mEFsXgFXiWMP7rFCrJOT+LDnEVgNp4CbRMvTLhaQ Q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qelf/q66O71yZenncscnbuJpH0/3x8 S6s1rM1Xcq5+9ty7scJ675S3ptt6nkT4tj8Vq6x5+SWxfZm6+lkTF44dVa98f/f3nqlaG6+x TOku5/piDvPs2KlvD//bpZ1kP+d3d6Tcea/DTTsrlGT7M0s5vH4bKLEUZyQaajEXFScCAGQR hfofAgAA X-CMS-MailID: 20170824014300epcas1p442352e3d95c164aa023bf16120e7f7a4 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: 20170824014300epcas1p442352e3d95c164aa023bf16120e7f7a4 X-RootMTR: 20170824014300epcas1p442352e3d95c164aa023bf16120e7f7a4 References: <1503538979-22693-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: 1987 Lines: 51 The existing {min|max}_freq sysfs nodes don't consider whether min/max_freq are available or not. Those sysfs nodes show just the stored value in the struct devfreq. The devfreq uses the OPP interface and then dev_pm_opp_{disable|add}() might change the state of the device's supported frequency. This patch shows the available minimum and maximum frequency through sysfs node. Signed-off-by: Chanwoo Choi --- drivers/devfreq/devfreq.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index be3d42f140ff..8b0bbfa0a50b 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -1148,7 +1148,14 @@ static ssize_t min_freq_store(struct device *dev, struct device_attribute *attr, static ssize_t min_freq_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%lu\n", to_devfreq(dev)->min_freq); + struct devfreq *df = to_devfreq(dev); + unsigned long min_freq = to_devfreq(dev)->min_freq; + unsigned long available_min_freq = find_available_min_freq(df); + + if (available_min_freq != 0 && min_freq < available_min_freq) + min_freq = available_min_freq; + + return sprintf(buf, "%lu\n", min_freq); } static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr, @@ -1186,7 +1193,14 @@ static ssize_t max_freq_store(struct device *dev, struct device_attribute *attr, static ssize_t max_freq_show(struct device *dev, struct device_attribute *attr, char *buf) { - return sprintf(buf, "%lu\n", to_devfreq(dev)->max_freq); + struct devfreq *df = to_devfreq(dev); + unsigned long max_freq = to_devfreq(dev)->max_freq; + unsigned long available_max_freq = find_available_max_freq(df); + + if (available_max_freq != 0 && max_freq > available_max_freq) + max_freq = available_max_freq; + + return sprintf(buf, "%lu\n", max_freq); } static DEVICE_ATTR_RW(max_freq); -- 1.9.1