From patchwork Sun Dec 9 20:02:59 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Walmsley X-Patchwork-Id: 1854461 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id D6646DF230 for ; Sun, 9 Dec 2012 20:09:31 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1Thn7t-00039Z-SK; Sun, 09 Dec 2012 20:05:25 +0000 Received: from utopia.booyaka.com ([74.50.51.50]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1Thn7b-00035R-H6 for linux-arm-kernel@lists.infradead.org; Sun, 09 Dec 2012 20:05:08 +0000 Received: (qmail 6858 invoked by uid 1019); 9 Dec 2012 20:05:05 -0000 MBOX-Line: From nobody Sun Dec 9 13:02:59 2012 Subject: [PATCH 01/12] ARM: OMAP2+: powerdomain: consolidate arch_pwrdm check code To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org From: Paul Walmsley Date: Sun, 09 Dec 2012 13:02:59 -0700 Message-ID: <20121209200257.3196.38184.stgit@dusk.lan> In-Reply-To: <20121209200108.3196.12452.stgit@dusk.lan> References: <20121209200108.3196.12452.stgit@dusk.lan> User-Agent: StGit/0.16-37-g27ac3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121209_150507_870641_859618BA X-CRM114-Status: GOOD ( 14.18 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.0 SPF_PASS SPF: sender matches SPF record -0.7 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Check for the presence of some of the arch_pwrdm function pointers during powerdomain setup, rather than in the individual functions. The primary motivation is to make the code slightly easier to read, but it also should avoid a few instructions in some hot paths. Signed-off-by: Paul Walmsley --- arch/arm/mach-omap2/powerdomain.c | 43 +++++++++++++++---------------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/arch/arm/mach-omap2/powerdomain.c b/arch/arm/mach-omap2/powerdomain.c index f81aee1..b67d721 100644 --- a/arch/arm/mach-omap2/powerdomain.c +++ b/arch/arm/mach-omap2/powerdomain.c @@ -385,9 +385,6 @@ static int _set_logic_retst_and_pwrdm_pwrst(struct powerdomain *pwrdm, if (!_pwrdm_pwrst_is_controllable(pwrdm)) return 0; - if (!arch_pwrdm || !arch_pwrdm->pwrdm_set_next_pwrst) - return -EINVAL; - if (!(pwrdm->pwrsts & (1 << pwrst))) return -EINVAL; @@ -395,13 +392,11 @@ static int _set_logic_retst_and_pwrdm_pwrst(struct powerdomain *pwrdm, if (!(pwrdm->pwrsts_logic_ret & (1 << logic))) return -EINVAL; - if (arch_pwrdm->pwrdm_set_logic_retst) { - ret = arch_pwrdm->pwrdm_set_logic_retst(pwrdm, logic); - if (ret) { - pr_err("%s: unable to set logic state %0x of powerdomain: %s\n", - __func__, logic, pwrdm->name); - return ret; - } + ret = arch_pwrdm->pwrdm_set_logic_retst(pwrdm, logic); + if (ret) { + pr_err("%s: unable to set logic state %0x of powerdomain: %s\n", + __func__, logic, pwrdm->name); + return ret; } } @@ -426,9 +421,6 @@ static int _pwrdm_read_next_fpwrst(struct powerdomain *pwrdm) int next_pwrst, next_logic, ret; u8 fpwrst; - if (!arch_pwrdm || !arch_pwrdm->pwrdm_read_next_pwrst) - return -EINVAL; - next_pwrst = arch_pwrdm->pwrdm_read_next_pwrst(pwrdm); if (next_pwrst < 0) return next_pwrst; @@ -653,9 +645,12 @@ static int _pwrdm_post_transition_cb(struct powerdomain *pwrdm, void *unused) * * Register the list of function pointers used to implement the * powerdomain functions on different OMAP SoCs. Should be called - * before any other pwrdm_register*() function. Returns -EINVAL if - * @po is null, -EEXIST if platform functions have already been - * registered, or 0 upon success. + * before any other pwrdm_register*() function. Several function + * pointers in @po are required to be non-null for the powerdomain + * code to function: pwrdm_wait_transition, pwrdm_read_next_pwrst, + * pwrdm_read_pwrst, pwrdm_set_next_pwrst, pwrdm_set_logic_retst, and + * pwrdm_read_prev_pwrst. Returns -EINVAL if @po is null, -EEXIST if + * platform functions have already been registered, or 0 upon success. */ int pwrdm_register_platform_funcs(struct pwrdm_ops *po) { @@ -665,6 +660,11 @@ int pwrdm_register_platform_funcs(struct pwrdm_ops *po) if (arch_pwrdm) return -EEXIST; + if (!po->pwrdm_wait_transition || !po->pwrdm_read_next_pwrst || + !po->pwrdm_read_pwrst || !po->pwrdm_set_next_pwrst || + !po->pwrdm_set_logic_retst || !po->pwrdm_read_prev_pwrst) + return -ENOENT; + arch_pwrdm = po; return 0; @@ -1221,7 +1221,7 @@ int pwrdm_read_next_fpwrst(struct powerdomain *pwrdm) int next_pwrst, next_logic, ret; u8 fpwrst; - if (!arch_pwrdm || !arch_pwrdm->pwrdm_read_next_pwrst) + if (!arch_pwrdm) return -EINVAL; pwrdm_lock(pwrdm); @@ -1264,8 +1264,7 @@ int pwrdm_set_fpwrst(struct powerdomain *pwrdm, enum pwrdm_func_state fpwrst) int ret = 0; bool hwsup = false; - if (!pwrdm || IS_ERR(pwrdm) || !arch_pwrdm || - !arch_pwrdm->pwrdm_read_pwrst) + if (!pwrdm || IS_ERR(pwrdm) || !arch_pwrdm) return -EINVAL; /* @@ -1334,9 +1333,6 @@ int pwrdm_read_fpwrst(struct powerdomain *pwrdm) if (!_pwrdm_pwrst_can_change(pwrdm)) return PWRDM_FUNC_PWRST_ON; - if (!arch_pwrdm->pwrdm_read_pwrst) - return -EINVAL; - pwrdm_lock(pwrdm); ret = _pwrdm_read_fpwrst(pwrdm); pwrdm_unlock(pwrdm); @@ -1362,9 +1358,6 @@ int pwrdm_read_prev_fpwrst(struct powerdomain *pwrdm) if (!_pwrdm_pwrst_can_change(pwrdm)) return PWRDM_FUNC_PWRST_ON; - if (!arch_pwrdm->pwrdm_read_prev_pwrst) - return -EINVAL; - pwrdm_lock(pwrdm); ret = _pwrdm_read_prev_fpwrst(pwrdm); pwrdm_unlock(pwrdm);