From patchwork Mon Sep 7 15:41:38 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 7136901 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 0ABCABEEC1 for ; Mon, 7 Sep 2015 15:43:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1CDBC20680 for ; Mon, 7 Sep 2015 15:43:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id B82AC20776 for ; Mon, 7 Sep 2015 15:43:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754059AbbIGPnG (ORCPT ); Mon, 7 Sep 2015 11:43:06 -0400 Received: from mailout1.samsung.com ([203.254.224.24]:33214 "EHLO mailout1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753803AbbIGPnA (ORCPT ); Mon, 7 Sep 2015 11:43:00 -0400 Received: from epcpsbgm1new.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NUB00GMICZIV640@mailout1.samsung.com>; Tue, 08 Sep 2015 00:42:58 +0900 (KST) X-AuditID: cbfee61a-f79a06d000005c6f-3a-55edb081a391 Received: from epmmp1.local.host ( [203.254.227.16]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 03.72.23663.180BDE55; Tue, 8 Sep 2015 00:42:58 +0900 (KST) Received: from AMDC1976.DIGITAL.local ([106.120.53.102]) by mmp1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NUB00JN0CXOGQ30@mmp1.samsung.com>; Tue, 08 Sep 2015 00:42:57 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Thomas Abraham , Kukjin Kim , Kukjin Kim , Viresh Kumar , Krzysztof Kozlowski , Marek Szyprowski , "Rafael J. Wysocki" Cc: Sylwester Nawrocki , Michael Turquette , Tomasz Figa , Lukasz Majewski , Heiko Stuebner , Chanwoo Choi , Kevin Hilman , Javier Martinez Canillas , Tobias Jakobi , Anand Moon , linux-samsung-soc@vger.kernel.org, linux-clk@vger.kernel.org, linux-pm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, b.zolnierkie@samsung.com Subject: [PATCH v4 1/4] PM / OPP: add dev_pm_opp_get_suspend_opp() helper Date: Mon, 07 Sep 2015 17:41:38 +0200 Message-id: <1441640501-13613-2-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1441640501-13613-1-git-send-email-b.zolnierkie@samsung.com> References: <1441640501-13613-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgkeLIzCtJLcpLzFFi42I5/e+xgG7ThrehBqtfMllsnLGe1eL6l+es Fv8fvWa1ePN2DZPF6xeGFr0LrrJZ9D9+zWzx9fAKRos3DzczWmx6fI3V4mPPPVaLy7vmsFl8 7j3CaDHj/D4mi3Ubb7FbrD1yl93i4ilXizOnL7FaHH7TzmrRsYzRom31B1aLVbv+MFps/Orh IO7x/kYru8fOWXfZPTat6mTzuHNtD5vH5iX1Hv+OsXts6QcKb7nazuLRt2UVo8f2a/OYPT5v kgvgjuKySUnNySxLLdK3S+DK+Pv4O2vBebGKo0+OsDQw/hLqYuTkkBAwkdjQOIMFwhaTuHBv PVsXIxeHkMBSRonXHz6yQji/GCWmr9sOVsUmYCUxsX0VI0hCRGARk8TC/VvBqpgFnrFItL7r ZgWpEhbwlGjZvRmoioODRUBV4srMapAwr4CHRPevfcwQ6+QkTh6bDFbOCVR+8s4uNhBbCKhm 27d/rBMYeRcwMqxilEgtSC4oTkrPNcxLLdcrTswtLs1L10vOz93ECI6XZ1I7GA/ucj/EKMDB qMTDe6PrTagQa2JZcWXuIUYJDmYlEd7YuW9DhXhTEiurUovy44tKc1KLDzFKc7AoifPKrnwW KiSQnliSmp2aWpBaBJNl4uCUamC8+Jlz3Yklx3zlLlbzHH6j/lkk8vrkhEs/bxcyOvccPqOv sXxJ12FJw1y7AzotOgwP8lzq9ttN3yX5OdArLn+b0gl3398FVzYe5ZkldE6z9/ETi+oKCfnZ 9Y5/H6V6c88suTaxMIRPbEoLw+qQ5ANJXMJTnr2TTnmbxvhpwUpv/6iW/7s3sngqsRRnJBpq MRcVJwIAZ59vtJMCAAA= Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add dev_pm_opp_get_suspend_opp() helper to obtain suspend opp. Cc: Viresh Kumar Cc: Thomas Abraham Cc: Javier Martinez Canillas Cc: Krzysztof Kozlowski Cc: Marek Szyprowski Cc: Tobias Jakobi Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/base/power/opp.c | 30 ++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 6 ++++++ 2 files changed, 36 insertions(+) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index eb25449..3d948ea 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -341,6 +341,36 @@ unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) EXPORT_SYMBOL_GPL(dev_pm_opp_get_max_clock_latency); /** + * dev_pm_opp_get_suspend_opp() - Get suspend opp + * @dev: device for which we do this operation + * + * Return: This function returns pointer to the suspend opp if it is + * defined, otherwise it returns NULL. + * + * Locking: This function must be called under rcu_read_lock(). opp is a rcu + * protected pointer. The reason for the same is that the opp pointer which is + * returned will remain valid for use with opp_get_{voltage, freq} only while + * under the locked area. The pointer returned must be used prior to unlocking + * with rcu_read_unlock() to maintain the integrity of the pointer. + */ +struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev) +{ + struct device_opp *dev_opp; + struct dev_pm_opp *opp; + + opp_rcu_lockdep_assert(); + + dev_opp = _find_device_opp(dev); + if (IS_ERR(dev_opp)) + opp = NULL; + else + opp = dev_opp->suspend_opp; + + return opp; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_suspend_opp); + +/** * dev_pm_opp_get_opp_count() - Get number of opps available in the opp list * @dev: device for which we do this operation * diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index cab7ba5..e817722 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -34,6 +34,7 @@ bool dev_pm_opp_is_turbo(struct dev_pm_opp *opp); int dev_pm_opp_get_opp_count(struct device *dev); unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev); +struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev); struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, @@ -80,6 +81,11 @@ static inline unsigned long dev_pm_opp_get_max_clock_latency(struct device *dev) return 0; } +static inline struct dev_pm_opp *dev_pm_opp_get_suspend_opp(struct device *dev) +{ + return NULL; +} + static inline struct dev_pm_opp *dev_pm_opp_find_freq_exact(struct device *dev, unsigned long freq, bool available) {