All of lore.kernel.org
 help / color / mirror / Atom feed
From: Paul Walmsley <paul@pwsan.com>
To: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/12] ARM: OMAP2+: powerdomain: consolidate arch_pwrdm check code
Date: Sun, 09 Dec 2012 13:02:59 -0700	[thread overview]
Message-ID: <20121209200257.3196.38184.stgit@dusk.lan> (raw)
In-Reply-To: <20121209200108.3196.12452.stgit@dusk.lan>

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 <paul@pwsan.com>
---
 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);



WARNING: multiple messages have this Message-ID (diff)
From: paul@pwsan.com (Paul Walmsley)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/12] ARM: OMAP2+: powerdomain: consolidate arch_pwrdm check code
Date: Sun, 09 Dec 2012 13:02:59 -0700	[thread overview]
Message-ID: <20121209200257.3196.38184.stgit@dusk.lan> (raw)
In-Reply-To: <20121209200108.3196.12452.stgit@dusk.lan>

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 <paul@pwsan.com>
---
 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);

  reply	other threads:[~2012-12-09 20:05 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-09 20:02 [PATCH 00/12] ARM: OMAP2+: powerdomain updates after the functional power state conversion Paul Walmsley
2012-12-09 20:02 ` Paul Walmsley
2012-12-09 20:02 ` Paul Walmsley [this message]
2012-12-09 20:02   ` [PATCH 01/12] ARM: OMAP2+: powerdomain: consolidate arch_pwrdm check code Paul Walmsley
2012-12-09 20:03 ` [PATCH 02/12] ARM: OMAP2+: PM/powerdomain: move the power state time tracking into the powerdomain code Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 03/12] ARM: OMAP2+: powerdomain: split pwrdm_state_switch() Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 04/12] ARM: OMAP2+: PM: clean up some debugfs functions Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 05/12] ARM: OMAP2+: powerdomain: remove some redundant checks; add some notes Paul Walmsley
2012-12-09 20:03 ` [PATCH 06/12] ARM: OMAP2+: CM: use the cached copy of the clockdomain's hwsup state Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 07/12] ARM: OMAP2+: powerdomain: cache the powerdomain next power state Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 08/12] ARM: OMAP2+: powerdomain: cache the powerdomain's previous " Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 09/12] ARM: OMAP2+: powerdomain: skip register reads for powerdomains known to be on Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-12 10:22   ` Vaibhav Hiremath
2012-12-12 10:22     ` Vaibhav Hiremath
2012-12-19 21:09   ` Jon Hunter
2012-12-19 21:09     ` Jon Hunter
2012-12-20 17:22     ` Paul Walmsley
2012-12-20 17:22       ` Paul Walmsley
2012-12-21  6:33       ` Santosh Shilimkar
2012-12-21  6:33         ` Santosh Shilimkar
2012-12-26  6:21   ` Bedia, Vaibhav
2012-12-26  6:21     ` Bedia, Vaibhav
2012-12-26  6:31     ` Bedia, Vaibhav
2012-12-26  6:31       ` Bedia, Vaibhav
2012-12-26 20:49     ` Paul Walmsley
2012-12-26 20:49       ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 10/12] ARM: OMAP2+: powerdomain: skip previous-power-state read if next_pwrst is ON Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 11/12] ARM: OMAP2xxx: powerdomain: add previous power state tracking Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2012-12-09 20:03 ` [PATCH 12/12] ARM: OMAP2xxx: PM: add pwrdm_(pre|post)_transition() calls to the 2xxx PM code Paul Walmsley
2012-12-09 20:03   ` Paul Walmsley
2013-01-04 14:26 ` [PATCH 00/12] ARM: OMAP2+: powerdomain updates after the functional power state conversion Tero Kristo
2013-01-04 14:26   ` Tero Kristo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20121209200257.3196.38184.stgit@dusk.lan \
    --to=paul@pwsan.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.