From patchwork Thu Sep 21 00:33:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chanwoo Choi X-Patchwork-Id: 9963091 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 60EC26056D for ; Thu, 21 Sep 2017 00:35:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 532162926A for ; Thu, 21 Sep 2017 00:35:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 480592927E; Thu, 21 Sep 2017 00:35:32 +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 500322926A for ; Thu, 21 Sep 2017 00:35:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751959AbdIUAf2 (ORCPT ); Wed, 20 Sep 2017 20:35:28 -0400 Received: from mailout2.samsung.com ([203.254.224.25]:40367 "EHLO mailout2.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751938AbdIUAd6 (ORCPT ); Wed, 20 Sep 2017 20:33:58 -0400 Received: from epcas1p1.samsung.com (unknown [182.195.41.45]) by mailout2.samsung.com (KnoxPortal) with ESMTP id 20170921003356epoutp02df0c37fad30a8c599ef1d188521d75ee~mOTerxpIz0156401564epoutp02I; Thu, 21 Sep 2017 00:33:56 +0000 (GMT) Received: from epsmges1p5.samsung.com (unknown [182.195.40.69]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20170921003356epcas1p462b1bd0341e8f6a01758045e23d913c1~mOTeWUiGo0792207922epcas1p4B; Thu, 21 Sep 2017 00:33:56 +0000 (GMT) Received: from epcas1p4.samsung.com ( [182.195.41.48]) by epsmges1p5.samsung.com (Symantec Messaging Gateway) with SMTP id C2.75.18934.4F803C95; Thu, 21 Sep 2017 09:33:56 +0900 (KST) Received: from epsmgms2p1new.samsung.com (unknown [182.195.42.142]) by epcas1p2.samsung.com (KnoxPortal) with ESMTP id 20170921003355epcas1p24e2126b498dedf4c1112bac783de187b~mOTeDZNkB0934309343epcas1p28; Thu, 21 Sep 2017 00:33:55 +0000 (GMT) X-AuditID: b6c32a39-f794a6d0000049f6-58-59c308f4f90e Received: from epmmp1.local.host ( [203.254.227.16]) by epsmgms2p1new.samsung.com (Symantec Messaging Gateway) with SMTP id 38.02.11757.3F803C95; Thu, 21 Sep 2017 09:33:55 +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 <0OWL00BYOTKJX990@mmp1.samsung.com>; Thu, 21 Sep 2017 09:33:55 +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-pm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/8] PM / devfreq: Show the available min/max frequency through sysfs node Date: Thu, 21 Sep 2017 09:33:47 +0900 Message-id: <1505954032-3327-4-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+NgFtrEKsWRmVeSWpSXmKPExsWy7bCmge4XjsORBu8f81tMvHGFxeL6l+es FpPuT2CxONv0ht3i8q45bBafe48wWtxuXMFm8XjFW3YHDo/Fe14yeW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m6YwF/zgr1h4uJ21gXEnbxcjJ4eEgInEhR3rmboYuTiEBHYy SjRdPsIK4fxglLh19yw7SBWbgJbE/hc32EBsEQE/ie3z1zOCFDELNDFKbHx2gAkkISwQL7Hl znuWLkYODhYBVYkl8yRAwrwCLhKtF5YyQ2yTk/iw5xHYTE4BV4lvZ7vAZgoB1Zx98ZptAiPP AkaGVYySqQXFuem5xUYFhnmp5XrFibnFpXnpesn5uZsYgWG07bBW3w7G+0viDzEKcDAq8fAG WB2MFGJNLCuuzD3EKMHBrCTCG/PwUKQQb0piZVVqUX58UWlOavEhRmkOFiVx3sy+GZFCAumJ JanZqakFqUUwWSYOTqkGRo6Us8smurewLq+oWjyN7VRj7CSHWXPfLvu0Pt7zfurkvhMGvfPl Sreu07G+fjV9XXaWSNjZaYlhFvb6+rPzQxbmNibmZLJOeNL8V3Nf0KZ6Z3+Omz16sx2MwxWV 7b+HnV80x13MS8ygi6F4lRrPd8PNZ256G1zftbmC2X1OFJ+WqLiQT42qEktxRqKhFnNRcSIA fTELXh8CAAA= X-CMS-MailID: 20170921003355epcas1p24e2126b498dedf4c1112bac783de187b 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: 20170921003355epcas1p24e2126b498dedf4c1112bac783de187b X-RootMTR: 20170921003355epcas1p24e2126b498dedf4c1112bac783de187b References: <1505954032-3327-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);