[PATCH 1/7] atmel_nand: check gpio validity before using it

Eric Bénard eric at eukrea.com
Sat Dec 7 04:36:54 EST 2013


else we get : "invalid GPIO -22"
(as enable_pin is EINVAL)

tested on SAMA5D35

Signed-off-by: Eric Bénard <eric at eukrea.com>
---
 drivers/mtd/nand/atmel_nand.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/nand/atmel_nand.c b/drivers/mtd/nand/atmel_nand.c
index a0f0966..658ae52 100644
--- a/drivers/mtd/nand/atmel_nand.c
+++ b/drivers/mtd/nand/atmel_nand.c
@@ -107,7 +107,7 @@ static struct nand_ecclayout atmel_pmecc_oobinfo;
  */
 static void atmel_nand_enable(struct atmel_nand_host *host)
 {
-	if (host->board->enable_pin)
+	if (gpio_is_valid(host->board->enable_pin))
 		gpio_set_value(host->board->enable_pin, 0);
 }
 
@@ -116,7 +116,7 @@ static void atmel_nand_enable(struct atmel_nand_host *host)
  */
 static void atmel_nand_disable(struct atmel_nand_host *host)
 {
-	if (host->board->enable_pin)
+	if (gpio_is_valid(host->board->enable_pin))
 		gpio_set_value(host->board->enable_pin, 1);
 }
 
-- 
1.8.3.1




More information about the barebox mailing list