Skip to contentSkip to conversation

gpio: add gpio_is_valid() to omap_gpio API

PATCH Superseded Nikita Kiryanov 2 participants 3 messages Nov 27, 2012 – Dec 10, 2012

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio: add gpio_is_valid() to omap_gpio API

Add gpio_is_valid() to omap_gpio API

---
 arch/arm/include/asm/omap_gpio.h |    8 ++++++++
 drivers/gpio/omap_gpio.c         |    4 ++--
 2 files changed, 10 insertions(+), 2 deletions(-)
arch/arm/include/asm/omap_gpio.h +8 -0
index 516cc42..be94770 100644
@@ -49,4 +49,12 @@ extern const struct gpio_bank *const omap_gpio_bank;
 
 #define METHOD_GPIO_24XX	4
 
+/**
+ * Check if gpio is valid.
+ *
+ * @param gpio	GPIO number
+ * @return 0 if ok, -1 on error
+ */
+int gpio_is_valid(int gpio);
+
 #endif /* _GPIO_H_ */
drivers/gpio/omap_gpio.c +2 -2
index fc89f2a..6e5b5f7 100644
@@ -53,7 +53,7 @@ static inline int get_gpio_index(int gpio)
 	return gpio & 0x1f;
 }
 
-static inline int gpio_valid(int gpio)
+int gpio_is_valid(int gpio)
 {
 	if (gpio < 0)
 		return -1;
@@ -64,7 +64,7 @@ static inline int gpio_valid(int gpio)
 
 static int check_gpio(int gpio)
 {
-	if (gpio_valid(gpio) < 0) {
+	if (gpio_is_valid(gpio) < 0) {
 		printf("ERROR : check_gpio: invalid GPIO %d\n", gpio);
 		return -1;
 	}
Signature · 1 line
1.7.10.4
#1 lore raw

PATCH v2 1/1 gpio: add gpio_is_valid() to omap_gpio API

Add gpio_is_valid() to omap_gpio API

---
Changes in V2:
- Changed the function to act as a predicate

 arch/arm/include/asm/omap_gpio.h |    7 +++++++
 drivers/gpio/omap_gpio.c         |   10 +++-------
 2 files changed, 10 insertions(+), 7 deletions(-)
arch/arm/include/asm/omap_gpio.h +7 -0
index 516cc42..1ebfa86 100644
@@ -49,4 +49,11 @@ extern const struct gpio_bank *const omap_gpio_bank;
 
 #define METHOD_GPIO_24XX	4
 
+/**
+ * Check if gpio is valid.
+ *
+ * @param gpio	GPIO number
+ * @return 1 if ok, 0 on error
+ */
+int gpio_is_valid(int gpio);
 #endif /* _GPIO_H_ */
drivers/gpio/omap_gpio.c +3 -7
index fc89f2a..a30d7f0 100644
@@ -53,18 +53,14 @@ static inline int get_gpio_index(int gpio)
 	return gpio & 0x1f;
 }
 
-static inline int gpio_valid(int gpio)
+int gpio_is_valid(int gpio)
 {
-	if (gpio < 0)
-		return -1;
-	if (gpio < 192)
-		return 0;
-	return -1;
+	return (gpio >= 0) && (gpio < 192);
 }
 
 static int check_gpio(int gpio)
 {
-	if (gpio_valid(gpio) < 0) {
+	if (!gpio_is_valid(gpio)) {
 		printf("ERROR : check_gpio: invalid GPIO %d\n", gpio);
 		return -1;
 	}
Signature · 1 line
1.7.10.4
#2 lore raw

PATCH v2 1/1 gpio: add gpio_is_valid() to omap_gpio API

Quoted 4 lines · Nikita Kiryanov

Add gpio_is_valid() to omap_gpio API

Applied to u-boot-ti/master, thanks!

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/20121210/20cd90c0/attachment.pgp>