From patchwork Wed Oct 11 03:09:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 9998637 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 DBB9060230 for ; Wed, 11 Oct 2017 03:11:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D669028860 for ; Wed, 11 Oct 2017 03:11:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CB70E28864; Wed, 11 Oct 2017 03:11:43 +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=unavailable 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 758EA28860 for ; Wed, 11 Oct 2017 03:11:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755039AbdJKDKs (ORCPT ); Tue, 10 Oct 2017 23:10:48 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:49781 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756299AbdJKDJt (ORCPT ); Tue, 10 Oct 2017 23:09:49 -0400 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20171011030947epoutp04212d974d17f42bf11515a9282c079fb1~sZVQ8hxDN2858428584epoutp04F; Wed, 11 Oct 2017 03:09:47 +0000 (GMT) Received: from epsmges1p2.samsung.com (unknown [182.195.40.70]) by epcas1p1.samsung.com (KnoxPortal) with ESMTP id 20171011030947epcas1p15301e94e001fe77036e98363c491ee87~sZVQaN18G2983329833epcas1p1S; Wed, 11 Oct 2017 03:09:47 +0000 (GMT) Received: from epcas1p2.samsung.com ( [182.195.41.46]) by epsmges1p2.samsung.com (Symantec Messaging Gateway) with SMTP id A6.66.33112.B7B8DD95; Wed, 11 Oct 2017 12:09:47 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20171011030946epcas1p40f32955da5dada46e95302701a0afb7d~sZVQIrk8k1917519175epcas1p4d; Wed, 11 Oct 2017 03:09:46 +0000 (GMT) X-AuditID: b6c32a36-c09ff70000018158-40-59dd8b7b30af Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id FB.CD.06995.A7B8DD95; Wed, 11 Oct 2017 12:09:46 +0900 (KST) Received: from localhost.localdomain ([10.113.62.212]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OXN00GRY24AU990@mmp1.samsung.com>; Wed, 11 Oct 2017 12:09:46 +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 v3 3/8] PM / devfreq: Show the available min/max frequency through sysfs node Date: Wed, 11 Oct 2017 12:09:19 +0900 Message-id: <1507691364-3899-4-git-send-email-cw00.choi@samsung.com> X-Mailer: git-send-email 1.8.0 In-reply-to: <1507691364-3899-1-git-send-email-cw00.choi@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrFKsWRmVeSWpSXmKPExsWy7bCmnm51991Ig3W3WSwm3rjCYnH9y3NW i0n3J7BYnG16w25xedccNovPvUcYLW43rmCzeLziLbsDh8fiPS+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ytTVOYC37wVyw83M7awLiTt4uRk0NCwETi9Mk+5i5GLg4hgZ2M Ek9nnWeCcH4wSmx5PJ0JpIpNQEti/4sbbCC2iICfxPb56xlBipgFmhgllvffAksIC8RLdLw4 xQpiswioSrz4cIERxOYVcJE4O/EqO8Q6OYkPex6B2ZwCrhKTZ50Cs4WAan6sfsk4gZFnASPD KkbJ1ILi3PTcYqMCw7zUcr3ixNzi0rx0veT83E2MwEDadlirbwfj/SXxhxgFOBiVeHgFrt+J FGJNLCuuzD3EKMHBrCTCa1F4N1KINyWxsiq1KD++qDQntfgQozQHi5I47+28Y5FCAumJJanZ qakFqUUwWSYOTqkGRhux8uVs3WUbZ9U4XF4QyWx54+uLZVP0pH0jkndsiV1v3CHC9ChF9mRH hL5tk8bpGqEFlo/rEgM3F2xab8R+vPbP7YVh7+VvPG7ZNqt9ZgWzuYtZ02WDcK5K39Oltgb1 5xuETM6KTeHWsJKyra7amv5zV0i5X57PsQ07VTOFfuT1LSxg/VKuxFKckWioxVxUnAgAvdFC 6yACAAA= X-CMS-MailID: 20171011030946epcas1p40f32955da5dada46e95302701a0afb7d 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: 20171011030946epcas1p40f32955da5dada46e95302701a0afb7d X-RootMTR: 20171011030946epcas1p40f32955da5dada46e95302701a0afb7d References: <1507691364-3899-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 2ce1fd0a1324..799a0cf75d39 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -1128,7 +1128,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, @@ -1162,7 +1169,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);