[U-Boot] [PATCH] Blackfin: cmd_gpio: allow port pins over 15

Andreas Pretzsch apr at cn-eng.de
Mon Jan 10 17:32:52 CET 2011


The pin portion of the specified GPIO was limited to 0..15.
While this is correct for Blackfins with different bank names (e.g.
BF537 with PF, PG, PH with 16 pins each), it's not sufficient for
Blackfins with linear naming like the BF561 (PF0..PF47).
Therefore check only for a valid GPIO number.

Attn.: Passing a # too high for the port will wrap over to the next
port(s), e.g. PA16 => PB0. Not a problem for correct scripts, though.

Signed-off-by: Andreas Pretzsch <apr at cn-eng.de>
---
 arch/blackfin/cpu/cmd_gpio.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/arch/blackfin/cpu/cmd_gpio.c b/arch/blackfin/cpu/cmd_gpio.c
index e96413b..9fd5a19 100644
--- a/arch/blackfin/cpu/cmd_gpio.c
+++ b/arch/blackfin/cpu/cmd_gpio.c
@@ -83,7 +83,11 @@ int do_gpio(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
 	/* grab the <#> portion */
 	ulong pin = simple_strtoul(str_pin + 1, NULL, 10);
-	if (pin > 15)
+	/* Attn.: passing a # too high for the port will wrap over to
+	 * the next port(s), e.g. PA16 => PB0.
+	 * Check relaxed due to linear ports (e.g. PF0..PF47 @ BF561).
+	 */
+	if (!gpio_is_valid(pin))
 		goto show_usage;
 
 	/* grab the pin before we tweak it */
-- 
1.7.2.3



More information about the U-Boot mailing list