public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
From: Rajendra Nayak <rnayak@ti.com>
To: linux-omap@vger.kernel.org
Cc: paul@pwsan.com, b-cousson@ti.com,
	linux-arm-kernel@lists.infradead.org,
	Rajendra Nayak <rnayak@ti.com>
Subject: [PATCH 3/3] OMAP2+: hwmod: Do not break iterator fn's if one fails
Date: Wed, 16 Feb 2011 17:41:25 +0530	[thread overview]
Message-ID: <1297858285-7056-4-git-send-email-rnayak@ti.com> (raw)
In-Reply-To: <1297858285-7056-3-git-send-email-rnayak@ti.com>

The iterator functions used to iterate over all
registered hwmods and all hwmods of a given class
break if one of the iterator functions fail.
Instead iterate over all the functions and return
an ORed return value back to the user.

Signed-off-by: Rajendra Nayak <rnayak@ti.com>
---
 arch/arm/mach-omap2/omap_hwmod.c |   23 ++++++++---------------
 1 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_hwmod.c b/arch/arm/mach-omap2/omap_hwmod.c
index 960461f..3cab82e 100644
--- a/arch/arm/mach-omap2/omap_hwmod.c
+++ b/arch/arm/mach-omap2/omap_hwmod.c
@@ -1568,25 +1568,21 @@ struct omap_hwmod *omap_hwmod_lookup(const char *name)
  *
  * Call @fn for each registered omap_hwmod, passing @data to each
  * function.  @fn must return 0 for success or any other value for
- * failure.  If @fn returns non-zero, the iteration across omap_hwmods
- * will stop and the non-zero return value will be passed to the
- * caller of omap_hwmod_for_each().  @fn is called with
+ * failure. Return value of all callback functions is OR'd and the
+ * value is passed back to the caller. @fn is called with
  * omap_hwmod_for_each() held.
  */
 int omap_hwmod_for_each(int (*fn)(struct omap_hwmod *oh, void *data),
 			void *data)
 {
 	struct omap_hwmod *temp_oh;
-	int ret;
+	int ret = 0;
 
 	if (!fn)
 		return -EINVAL;
 
-	list_for_each_entry(temp_oh, &omap_hwmod_list, node) {
-		ret = (*fn)(temp_oh, data);
-		if (ret)
-			break;
-	}
+	list_for_each_entry(temp_oh, &omap_hwmod_list, node)
+		ret |= (*fn)(temp_oh, data);
 
 	return ret;
 }
@@ -2127,8 +2123,7 @@ int omap_hwmod_read_hardreset(struct omap_hwmod *oh, const char *name)
  * @user: arbitrary context data to pass to the callback function
  *
  * For each omap_hwmod of class @classname, call @fn.
- * If the callback function returns something other than
- * zero, the iterator is terminated, and the callback function's return
+ * Return value of all callback functions is OR'd and the
  * value is passed back to the caller.  Returns 0 upon success, -EINVAL
  * if @classname or @fn are NULL, or passes back the error code from @fn.
  */
@@ -2150,14 +2145,12 @@ int omap_hwmod_for_each_by_class(const char *classname,
 		if (!strcmp(temp_oh->class->name, classname)) {
 			pr_debug("omap_hwmod: %s: %s: calling callback fn\n",
 				 __func__, temp_oh->name);
-			ret = (*fn)(temp_oh, user);
-			if (ret)
-				break;
+			ret |= (*fn)(temp_oh, user);
 		}
 	}
 
 	if (ret)
-		pr_debug("omap_hwmod: %s: iterator terminated early: %d\n",
+		pr_debug("omap_hwmod: %s: one or more callback fn failed: %d\n",
 			 __func__, ret);
 
 	return ret;
-- 
1.7.0.4


  reply	other threads:[~2011-02-16 12:11 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-16 12:11 [PATCH 0/3] OMAP2+ hwmod fixes Rajendra Nayak
2011-02-16 12:11 ` [PATCH 1/3] OMAP2+: hwmod: Avoid setup if clock lookup failed Rajendra Nayak
2011-02-16 12:11   ` [PATCH 2/3] OMAP2+: hwmod: Fix what _init_clock returns Rajendra Nayak
2011-02-16 12:11     ` Rajendra Nayak [this message]
2011-02-18 14:51     ` Cousson, Benoit
2011-02-16 12:35   ` [PATCH 1/3] OMAP2+: hwmod: Avoid setup if clock lookup failed Sergei Shtylyov
2011-02-18 17:34   ` Cousson, Benoit
2011-02-16 13:07 ` [PATCH 0/3] OMAP2+ hwmod fixes Cousson, Benoit
2011-02-16 13:43   ` Rajendra Nayak
2011-02-18 14:44     ` Cousson, Benoit
2011-02-21 16:55       ` Paul Walmsley
2011-02-22 13:11         ` Rajendra Nayak
2011-02-22 19:09           ` Paul Walmsley
2011-02-23 10:05             ` Rajendra Nayak
2011-03-01 16:57               ` Cousson, Benoit
2011-03-03  6:08                 ` Paul Walmsley

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=1297858285-7056-4-git-send-email-rnayak@ti.com \
    --to=rnayak@ti.com \
    --cc=b-cousson@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=paul@pwsan.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox