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: 6757011 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 4F6E2C05AC for ; Thu, 9 Jul 2015 15:46:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7219F206B8 for ; Thu, 9 Jul 2015 15:46:38 +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 AC0172049E for ; Thu, 9 Jul 2015 15:46:36 +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 1ZDE0S-0000ib-LA; Thu, 09 Jul 2015 15:45:00 +0000 Received: from mailout3.samsung.com ([203.254.224.33]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1ZDE0F-0000Ml-9O for linux-arm-kernel@lists.infradead.org; Thu, 09 Jul 2015 15:44:48 +0000 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> for linux-arm-kernel@lists.infradead.org; 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 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= X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150709_084447_491042_3A6ABC1D X-CRM114-Status: GOOD ( 13.71 ) X-Spam-Score: -7.2 (-------) 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 , Tobias Jakobi , Anand Moon , linux-pm@vger.kernel.org, Tomasz Figa , linux-kernel@vger.kernel.org, Chanwoo Choi , b.zolnierkie@samsung.com, linux-samsung-soc@vger.kernel.org, Javier Martinez Canillas , linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.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.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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;