From: John Ogness <john.ogness@linutronix.de>
To: s.hauer@pengutronix.de
Cc: spi-devel-general@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] SPI/i.MX: fix broken error handling for gpio_request
Date: Tue, 24 Nov 2009 17:53:07 +0100 [thread overview]
Message-ID: <807htfsw3w.fsf@merkur.tec.linutronix.de> (raw)
i.MX35-provided chipselects are represented using negative numbers. If
gpio_request() fails and the previous chipselect was a negative number,
the while loop is endless (i is never decremented).
Also, the error loop would never call gpio_free on chipselect[0].
And finally, the error message was missing an endline.
This patch is against 2.6.32-rc8.
Signed-off-by: John Ogness <john.ogness@linutronix.de>
---
spi_imx.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
--- a/drivers/spi/spi_imx.c
+++ b/drivers/spi/spi_imx.c
@@ -513,11 +513,12 @@ static int __init spi_imx_probe(struct p
continue;
ret = gpio_request(spi_imx->chipselect[i], DRIVER_NAME);
if (ret) {
- i--;
- while (i > 0)
+ while (i > 0) {
+ i--;
if (spi_imx->chipselect[i] >= 0)
- gpio_free(spi_imx->chipselect[i--]);
- dev_err(&pdev->dev, "can't get cs gpios");
+ gpio_free(spi_imx->chipselect[i]);
+ }
+ dev_err(&pdev->dev, "can't get cs gpios\n");
goto out_master_put;
}
}
reply other threads:[~2009-11-24 16:53 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=807htfsw3w.fsf@merkur.tec.linutronix.de \
--to=john.ogness@linutronix.de \
--cc=s.hauer@pengutronix.de \
--cc=spi-devel-general@lists.sourceforge.net \
/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
all inboxes | Powered by JetHome®