From patchwork Thu Aug 24 01:42:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 9918863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 078A8608B9 for ; Thu, 24 Aug 2017 01:44:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED47028ADA for ; Thu, 24 Aug 2017 01:44:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB76C28ADF; Thu, 24 Aug 2017 01:44:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5420F28AE4 for ; Thu, 24 Aug 2017 01:44:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751759AbdHXBoi (ORCPT ); Wed, 23 Aug 2017 21:44:38 -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 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout3.samsung.com (KnoxPortal) with ESMTP id 20170824014300epoutp03cb6e6e0744ad7be3a3c9350bfa392156~dpLyhl6YJ1300513005epoutp03W; Thu, 24 Aug 2017 01:43:00 +0000 (GMT) Received: from epsmges1p1.samsung.com (unknown [182.195.40.66]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20170824014300epcas1p4ca74c135beec309c6b7652b44596e6e3~dpLyRJcGG2064320643epcas1p4K; Thu, 24 Aug 2017 01:43:00 +0000 (GMT) Received: from epcas1p1.samsung.com ( [182.195.41.45]) by epsmges1p1.samsung.com (Symantec Messaging Gateway) with SMTP id 33.A3.22848.42F2E995; Thu, 24 Aug 2017 10:43:00 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20170824014300epcas1p442352e3d95c164aa023bf16120e7f7a4~dpLx-dyHf2064320643epcas1p4J; Thu, 24 Aug 2017 01:43:00 +0000 (GMT) X-AuditID: b6c32a35-f798c6d000005940-70-599e2f2418cd Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 9F.A7.11757.32F2E995; Thu, 24 Aug 2017 10:43:00 +0900 (KST) Received: from localhost.localdomain ([10.113.62.212]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OV600BON23MQ710@mmp2.samsung.com>; Thu, 24 Aug 2017 10:42:59 +0900 (KST) 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 xaT7E1gszja9Ybe4vGsOm8Xn3iOMFrcbV7BZP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LpuU1JzMstQifbsEroyG1+dZC37wVxw/kdXAuJO3i5GTQ0LAROLj8xlMXYxcHEIC6xgl 9k5dwgLh/GCU2HF8HTtIFZuAlsT+FzfYQGwRAT+J7fPXM4IUMQs0MUos778FlhAWiJPYs+UK WAOLgKrExIU7mEFsXgFXiWMP7rFCrJOT+LDnEVgNp4CbRMvTLhYQWwioZk/fUcYJjDwLGBlW MUqmFhTnpucWGxUY5qWW6xUn5haX5qXrJefnbmIEhtG2w1p9OxjvL4k/xCjAwajEw3th4dxI IdbEsuLK3EOMEhzMSiK8e9XnRQrxpiRWVqUW5ccXleakFh9ilOZgURLnzeybESkkkJ5Ykpqd mlqQWgSTZeLglGpgzK2YcdTVfNfzwAnntvkIq9zlCUqelf/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-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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);