Skip to contentSkip to conversation

gpio: omap_gpio: Fix valid gpio range for AM33XX

PATCH Superseded Axel Lin 4 participants 4 messages Jun 20, 2013 GPIO

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 gpio: omap_gpio: Fix valid gpio range for AM33XX

AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.

---
 drivers/gpio/omap_gpio.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpio/omap_gpio.c +4 -0
index a30d7f0..9aa6d41 100644
@@ -55,7 +55,11 @@ static inline int get_gpio_index(int gpio)
 
 int gpio_is_valid(int gpio)
 {
+#if defined(CONFIG_AM33XX)
+	return (gpio >= 0) && (gpio < 128);
+#else
 	return (gpio >= 0) && (gpio < 192);
+#endif
 }
 
 static int check_gpio(int gpio)
Signature · 1 line
1.8.1.2
#1 lore raw

PATCH 1/1 gpio: omap_gpio: Fix valid gpio range for AM33XX

Quoted 3 lines · Axel Lin

AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20130620/d7d57441/attachment.pgp>
#2 lore raw

PATCH 1/1 gpio: omap_gpio: Fix valid gpio range for AM33XX

In reply to Axel Lin
Quoted 12 lines · Axel Lin

AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.

---
 drivers/gpio/omap_gpio.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpio/omap_gpio.c +0 -0
index a30d7f0..9aa6d41 100644

drivers/gpio/omap_gpio.c static inline int get_gpio_index(int gpio) · line 63

Quoted 9 lines
drivers/gpio/omap_gpio.c +4 -0
@@ -55,7 +55,11 @@ static inline int get_gpio_index(int gpio)
 
 int gpio_is_valid(int gpio)
 {
+#if defined(CONFIG_AM33XX)
+	return (gpio >= 0) && (gpio < 128);
+#else
 	return (gpio >= 0) && (gpio < 192);
+#endif
 }

Those ifdef's in the code really ugly and frowned upon. Better would be to move this into a define in the top of the C file:

#if defined(CONFIG_AM33XX)
#define CONFIG_OMAP_MAX_GPIO 128
#else
#define CONFIG_OMAP_MAX_GPIO 192
#endif

And then use this define in the code:

	return (gpio >= 0) && (gpio < CONFIG_OMAP_MAX_GPIO);

Thanks,
Stefan

#3 lore raw

PATCH 1/1 gpio: omap_gpio: Fix valid gpio range for AM33XX

Dear Stefan Roese,

Quoted 37 lines · Axel Lin
Quoted 25 lines

AM33XX has 4 gpio banks, thus the valid gpio range should be 0 ... 127.

---

 drivers/gpio/omap_gpio.c | 4 ++++
 1 file changed, 4 insertions(+)
drivers/gpio/omap_gpio.c +4 -0
index a30d7f0..9aa6d41 100644
@@ -55,7 +55,11 @@ static inline int get_gpio_index(int gpio)
 
 int gpio_is_valid(int gpio)
 {
 
+#if defined(CONFIG_AM33XX)
+	return (gpio >= 0) && (gpio < 128);
+#else
 
 	return (gpio >= 0) && (gpio < 192);
 
+#endif
Quoted 1 line

}

Those ifdef's in the code really ugly and frowned upon. Better would be to move this into a define in the top of the C file:

#if defined(CONFIG_AM33XX)
#define CONFIG_OMAP_MAX_GPIO 128
#else
#define CONFIG_OMAP_MAX_GPIO 192
#endif

Quoted 6 lines

And then use this define in the code:

	return (gpio >= 0) && (gpio < CONFIG_OMAP_MAX_GPIO);

Thanks,
Stefan

You were faster ;-) and I agree with this method.

Best regards,
Marek Vasut