From patchwork Tue Sep 8 16:41:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 7142601 Return-Path: X-Original-To: patchwork-linux-arm@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 05811BEEC1 for ; Tue, 8 Sep 2015 16:44:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 187B020834 for ; Tue, 8 Sep 2015 16:44:21 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 31C0A2082A for ; Tue, 8 Sep 2015 16:44:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZLy7-0001Br-Fu; Tue, 08 Sep 2015 16:42:03 +0000 Received: from mailout1.samsung.com ([203.254.224.24]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZZLy3-00010e-RP for linux-arm-kernel@lists.infradead.org; Tue, 08 Sep 2015 16:42:01 +0000 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 <0NUD00WCWADD3410@mailout1.samsung.com> for linux-arm-kernel@lists.infradead.org; Wed, 09 Sep 2015 01:41:37 +0900 (KST) X-AuditID: cbfee61a-f79a06d000005c6f-62-55ef0fc1888c Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1new.samsung.com (EPCPMTA) with SMTP id 70.C3.23663.1CF0FE55; Wed, 9 Sep 2015 01:41:37 +0900 (KST) Received: from AMDC1976.DIGITAL.local ([106.120.53.102]) by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0NUD00BDDACMIH50@mmp2.samsung.com>; Wed, 09 Sep 2015 01:41:37 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Thomas Abraham , Kukjin Kim , Kukjin Kim , Viresh Kumar , Krzysztof Kozlowski , Marek Szyprowski , "Rafael J. Wysocki" Subject: [PATCH v5 1/4] PM / OPP: add dev_pm_opp_get_suspend_opp() helper Date: Tue, 08 Sep 2015 18:41:01 +0200 Message-id: <1441730464-7947-2-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1441730464-7947-1-git-send-email-b.zolnierkie@samsung.com> References: <1441730464-7947-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpkkeLIzCtJLcpLzFFi42I5/e+xoO5B/vehBid3aVhsnLGe1eL6l+es Fv8fvWa1ePN2DZPF6xeGFr0LrrJZ9D9+zWzx9fAKRos3DzczWmx6fI3V4mPPPVaLy7vmsFl8 7j3CaDHj/D4mi3Ubb7FbrD1yl93i4ilXizOnL7FaHH7TzmrRsYzRom31B1aLVbv+MFps/Orh IO7x/kYru8fOWXfZPTat6mTzuHNtD5vH5iX1Hv+OsXts6QcKb7nazuLRt2UVo8f2a/OYPT5v kgvgjuKySUnNySxLLdK3S+DKaDi1mrXgqljFj6kXmBoYG4S7GDk5JARMJK7+/84GYYtJXLi3 Hsjm4hASmMUo8WPNVCjnF6PEpPddjCBVbAJWEhPbVzGCJEQEFjFJLNy/lRXEYRZ4xiLR+q6b FaRKWMBTYtP+NSwgNouAqsTUO1eYQWxeAXeJRe/WM0Lsk5M4eWwyWD2ngIdEy+8ZTCC2EFBN 18nVjBMYeRcwMqxilEgtSC4oTkrPNcxLLdcrTswtLs1L10vOz93ECI6YZ1I7GA/ucj/EKMDB qMTD2+D1LlSINbGsuDL3EKMEB7OSCG/2b6AQb0piZVVqUX58UWlOavEhRmkOFiVxXtmVz0KF BNITS1KzU1MLUotgskwcnFINjKKT188+Jj1FmN04Sytm6ffQkHXei0+9+n9Z8tjRtDdRgX6m BixPHm/vWHKa13jjVdeOyuK9u19dNtr8xHtPZNKB5zk/8ww93e/l7M9cnJ8i+86h0G1OGt87 qfpFsudmX7NjKP5kknJmtslsAe4V244fq5P8Ot0n6r5B/m2LsL2bmb7w8RpxWiuxFGckGmox FxUnAgCuQ1+XlAIAAA== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150908_094200_044709_E6BD185B X-CRM114-Status: GOOD ( 15.43 ) X-Spam-Score: -6.9 (------) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Lukasz Majewski , Kevin Hilman , Heiko Stuebner , Javier Martinez Canillas , Anand Moon , Michael Turquette , linux-pm@vger.kernel.org, Tomasz Figa , linux-kernel@vger.kernel.org, Chanwoo Choi , b.zolnierkie@samsung.com, Tobias Jakobi , linux-arm-kernel@lists.infradead.org, Sylwester Nawrocki , linux-clk@vger.kernel.org, linux-samsung-soc@vger.kernel.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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: Thomas Abraham Cc: Javier Martinez Canillas Cc: Krzysztof Kozlowski Cc: Marek Szyprowski Cc: Tobias Jakobi Acked-by: Viresh Kumar 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) {