All of lore.kernel.org
 help / color / mirror / Atom feed
From: roel.kluin@gmail.com (Roel Kluin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH] MX1/MX2: -EINVAL overwritten in second iteration in mxc_gpio_setup_multiple_pins()
Date: Wed, 03 Feb 2010 20:19:00 +0100	[thread overview]
Message-ID: <4B69CC24.3050503@gmail.com> (raw)

Due to the `ret = gpio_request()' below in the loop, the initial -EINVAL value
of ret is overwritten. 

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Not 100% sure this is needed, please review. One more question: is it ok
to return 0 when count is 0 (and nothing is done)?

diff --git a/arch/arm/plat-mxc/iomux-mx1-mx2.c b/arch/arm/plat-mxc/iomux-mx1-mx2.c
index a37163c..25023ac 100644
--- a/arch/arm/plat-mxc/iomux-mx1-mx2.c
+++ b/arch/arm/plat-mxc/iomux-mx1-mx2.c
@@ -116,14 +116,16 @@ int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
 	int i;
 	unsigned gpio;
 	unsigned mode;
-	int ret = -EINVAL;
+	int ret;
 
 	for (i = 0; i < count; i++) {
 		gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK);
 		mode = *p & ~(GPIO_PIN_MASK | GPIO_PORT_MASK);
 
-		if (gpio >= (GPIO_PORT_MAX + 1) * 32)
+		if (gpio >= (GPIO_PORT_MAX + 1) * 32) {
+			ret = -EINVAL;
 			goto setup_error;
+		}
 
 		ret = gpio_request(gpio, label);
 		if (ret)

WARNING: multiple messages have this Message-ID (diff)
From: Roel Kluin <roel.kluin@gmail.com>
To: Sascha Hauer <kernel@pengutronix.de>,
	linux-arm-kernel@lists.infradead.org,
	Andrew Morton <akpm@linux-foundation.org>,
	LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] MX1/MX2: -EINVAL overwritten in second iteration in mxc_gpio_setup_multiple_pins()
Date: Wed, 03 Feb 2010 20:19:00 +0100	[thread overview]
Message-ID: <4B69CC24.3050503@gmail.com> (raw)

Due to the `ret = gpio_request()' below in the loop, the initial -EINVAL value
of ret is overwritten. 

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Not 100% sure this is needed, please review. One more question: is it ok
to return 0 when count is 0 (and nothing is done)?

diff --git a/arch/arm/plat-mxc/iomux-mx1-mx2.c b/arch/arm/plat-mxc/iomux-mx1-mx2.c
index a37163c..25023ac 100644
--- a/arch/arm/plat-mxc/iomux-mx1-mx2.c
+++ b/arch/arm/plat-mxc/iomux-mx1-mx2.c
@@ -116,14 +116,16 @@ int mxc_gpio_setup_multiple_pins(const int *pin_list, unsigned count,
 	int i;
 	unsigned gpio;
 	unsigned mode;
-	int ret = -EINVAL;
+	int ret;
 
 	for (i = 0; i < count; i++) {
 		gpio = *p & (GPIO_PIN_MASK | GPIO_PORT_MASK);
 		mode = *p & ~(GPIO_PIN_MASK | GPIO_PORT_MASK);
 
-		if (gpio >= (GPIO_PORT_MAX + 1) * 32)
+		if (gpio >= (GPIO_PORT_MAX + 1) * 32) {
+			ret = -EINVAL;
 			goto setup_error;
+		}
 
 		ret = gpio_request(gpio, label);
 		if (ret)

             reply	other threads:[~2010-02-03 19:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-03 19:19 Roel Kluin [this message]
2010-02-03 19:19 ` [PATCH] MX1/MX2: -EINVAL overwritten in second iteration in mxc_gpio_setup_multiple_pins() Roel Kluin
2010-02-03 20:56 ` Uwe Kleine-König
2010-02-03 20:56   ` Uwe Kleine-König

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=4B69CC24.3050503@gmail.com \
    --to=roel.kluin@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.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.