From patchwork Thu Jul 9 15:43:35 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bartlomiej Zolnierkiewicz X-Patchwork-Id: 6756831 Return-Path: X-Original-To: patchwork-linux-samsung-soc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 7784F9F54C for ; Thu, 9 Jul 2015 15:44:45 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 984C020499 for ; Thu, 9 Jul 2015 15:44:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7F4E3206AC for ; Thu, 9 Jul 2015 15:44:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752738AbbGIPog (ORCPT ); Thu, 9 Jul 2015 11:44:36 -0400 Received: from mailout3.samsung.com ([203.254.224.33]:54334 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751866AbbGIPo1 (ORCPT ); Thu, 9 Jul 2015 11:44:27 -0400 Received: from epcpsbgm1.samsung.com (epcpsbgm1 [203.254.230.26]) by mailout3.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0NR802CNG9216490@mailout3.samsung.com>; Fri, 10 Jul 2015 00:44:25 +0900 (KST) X-AuditID: cbfee61a-f79516d000006302-70-559e96d85113 Received: from epmmp2 ( [203.254.227.17]) by epcpsbgm1.samsung.com (EPCPMTA) with SMTP id C8.9C.25346.8D69E955; Fri, 10 Jul 2015 00:44:25 +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 <0NR800J1C91IAM40@mmp2.samsung.com>; Fri, 10 Jul 2015 00:44:24 +0900 (KST) From: Bartlomiej Zolnierkiewicz To: Thomas Abraham , Sylwester Nawrocki , Michael Turquette , Kukjin Kim , Kukjin Kim , Viresh Kumar , Krzysztof Kozlowski Cc: 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 v2 1/7] opp: add dev_pm_opp_get_turbo_mode_setting() helper Date: Thu, 09 Jul 2015 17:43:35 +0200 Message-id: <1436456621-29839-2-git-send-email-b.zolnierkie@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1436456621-29839-1-git-send-email-b.zolnierkie@samsung.com> References: <1436456621-29839-1-git-send-email-b.zolnierkie@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrHLMWRmVeSWpSXmKPExsVy+t9jQd2b0+aFGpz9z2ixccZ6VovrX56z Wvx/9JrV4trvGWwWr18YWvQuuMpm0f/4NbPF18MrGC3ePNzMaLHp8TVWi48991gtLu+aw2bx ufcIo8WM8/uYLNZtvMVucfGUq8XhN+2sFh3LGC3aVn9gtVi16w/Qgq8eDqIe72+0snv8nd3K 7LFz1l12j02rOtk87lzbw+axeUm9x79j7B59W1Yxemy/No/Z4/MmuQCuKC6blNSczLLUIn27 BK6My9+WMBXcEKu4f/IaUwNjh3AXIyeHhICJRPvPfhYIW0ziwr31bF2MXBxCAtMZJZZNuQDl /GKU2DNhDjNIFZuAlcTE9lWMIAkRgRVMEtOf7GMHcZgFWlkklr+dyQhSJSzgLfHn3i02EJtF QFXi5cHHTCA2r4CHxMFDIA0g++QkTh6bzNrFyMHBKeAp8fhvDEhYCKjk7/dfLBMYeRcwMqxi FE0tSC4oTkrPNdQrTswtLs1L10vOz93ECI6FZ1I7GFc2WBxiFOBgVOLhbdg5N1SINbGsuDL3 EKMEB7OSCO/l/nmhQrwpiZVVqUX58UWlOanFhxilOViUxHlP5vuECgmkJ5akZqemFqQWwWSZ ODilGhjlruxa49R+gjt0qcJEy0Qr9T49nZUT9a+drVhcdudCy42bi92nPbz79872Pb5qrP5s R6X3dq82LvO7O5PTaX1LWVWK6Jmpki9FezLSn4p9eyplI/EqYS3TQxO1LMavAtaiHQ+PB2zd 9K726RSnnxffZa4Xm/J7xk+Jh83XPj/XXS66si2uM6dOiaU4I9FQi7moOBEA6hh4f4ECAAA= 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=-7.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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_turbo_mode_setting() helper for getting turbo mode setting for a given opp. Cc: Tomasz Figa Cc: Michael Turquette Cc: Javier Martinez Canillas Cc: Thomas Abraham Cc: Viresh Kumar Signed-off-by: Bartlomiej Zolnierkiewicz --- drivers/base/power/opp.c | 31 +++++++++++++++++++++++++++++++ include/linux/pm_opp.h | 7 +++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c index e24502a2..6b34b2a 100644 --- a/drivers/base/power/opp.c +++ b/drivers/base/power/opp.c @@ -287,6 +287,37 @@ unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) EXPORT_SYMBOL_GPL(dev_pm_opp_get_freq); /** + * dev_pm_opp_get_turbo_mode_setting() - Gets the turbo setting + * @opp: opp for which turbo mode setting has to be returned for + * + * Return: turbo mode setting corresponding to the opp (true or false) + * + * Locking: This function must be called under rcu_read_lock(). opp is a rcu + * protected pointer. This means that opp which could have been fetched by + * opp_find_freq_{exact,ceil,floor} functions is valid as long as we are + * under RCU lock. The pointer returned by the opp_find_freq family must be + * used in the same section as the usage of this function with the pointer + * prior to unlocking with rcu_read_unlock() to maintain the integrity of the + * pointer. + */ +bool dev_pm_opp_get_turbo_mode_setting(struct dev_pm_opp *opp) +{ + struct dev_pm_opp *tmp_opp; + bool f = false; + + opp_rcu_lockdep_assert(); + + tmp_opp = rcu_dereference(opp); + if (unlikely(IS_ERR_OR_NULL(tmp_opp)) || !tmp_opp->available) + pr_err("%s: Invalid parameters\n", __func__); + else + f = tmp_opp->turbo; + + return f; +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_turbo_mode_setting); + +/** * dev_pm_opp_get_max_clock_latency() - Get max clock latency in nanoseconds * @dev: device for which we do this operation * diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index bb52fae..7856baf 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -30,6 +30,8 @@ unsigned long dev_pm_opp_get_voltage(struct dev_pm_opp *opp); unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp); +bool dev_pm_opp_get_turbo_mode_setting(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); @@ -63,6 +65,11 @@ static inline unsigned long dev_pm_opp_get_freq(struct dev_pm_opp *opp) return 0; } +static inline bool dev_pm_opp_get_turbo_mode_setting(struct dev_pm_opp *opp) +{ + return false; +} + static inline int dev_pm_opp_get_opp_count(struct device *dev) { return 0;