]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
gpio: am33xx: print error messages for invalid GPIO requests
authorLothar Waßmann <LW@KARO-electronics.de>
Mon, 25 Aug 2014 12:25:01 +0000 (14:25 +0200)
committerLothar Waßmann <LW@KARO-electronics.de>
Mon, 25 Aug 2014 12:25:01 +0000 (14:25 +0200)
drivers/gpio/am33xx_gpio.c

index 2b4074551a8d1d7a6abe0e491896c4f4865cc762..f34fdc6bd845ff8e2154f962e4004eb017cff08f 100644 (file)
@@ -45,8 +45,11 @@ static unsigned long gpio_map[ARRAY_SIZE(gpio_base)] __attribute__((section("dat
 
 int gpio_request(unsigned gpio, const char *name)
 {
-       if (gpio >= MAX_GPIO)
+       if (gpio >= MAX_GPIO) {
+               printf("ERROR: Invalid GPIO: %u (GPIO%u_%u)\n", gpio,
+                       gpio / 32, gpio % 32);
                return -EINVAL;
+       }
        if (test_and_set_bit(gpio, gpio_map))
                return -EBUSY;
        return 0;
@@ -54,9 +57,11 @@ int gpio_request(unsigned gpio, const char *name)
 
 int gpio_free(unsigned gpio)
 {
-       if (gpio >= MAX_GPIO)
+       if (gpio >= MAX_GPIO) {
+               printf("ERROR: Invalid GPIO: %u (GPIO%u_%u)\n", gpio,
+                       gpio / 32, gpio % 32);
                return -EINVAL;
-
+       }
        if (test_bit(gpio, gpio_map))
                __clear_bit(gpio, gpio_map);
        else
@@ -70,9 +75,11 @@ int gpio_set_value(unsigned gpio, int val)
        int bank = gpio / 32;
        int mask = 1 << (gpio % 32);
 
-       if (bank >= ARRAY_SIZE(gpio_base))
+       if (bank >= ARRAY_SIZE(gpio_base)) {
+               printf("ERROR: Invalid GPIO: %u (GPIO%u_%u)\n", gpio,
+                       gpio / 32, gpio % 32);
                return -EINVAL;
-
+       }
        if (val)
                writel(mask, &gpio_base[bank]->setdataout);
        else
@@ -85,8 +92,11 @@ int gpio_direction_input(unsigned gpio)
        int bank = gpio / 32;
        int mask = 1 << (gpio % 32);
 
-       if (bank >= ARRAY_SIZE(gpio_base))
+       if (bank >= ARRAY_SIZE(gpio_base)) {
+               printf("ERROR: Invalid GPIO: %u (GPIO%u_%u)\n", gpio,
+                       gpio / 32, gpio % 32);
                return -EINVAL;
+       }
 
        writel(readl(&gpio_base[bank]->oe) | mask, &gpio_base[bank]->oe);
        return 0;
@@ -97,9 +107,11 @@ int gpio_direction_output(unsigned gpio, int val)
        int bank = gpio / 32;
        int mask = 1 << (gpio % 32);
 
-       if (bank >= ARRAY_SIZE(gpio_base))
+       if (bank >= ARRAY_SIZE(gpio_base)) {
+               printf("ERROR: Invalid GPIO: %u (GPIO%u_%u)\n", gpio,
+                       gpio / 32, gpio % 32);
                return -EINVAL;
-
+       }
        gpio_set_value(gpio, val);
        writel(readl(&gpio_base[bank]->oe) & ~mask, &gpio_base[bank]->oe);
        return 0;