diff mbox

[1/5] gpiolib: introduce set_debounce method

Message ID 20100521064925.GF925@nokia.com (mailing list archive)
State Awaiting Upstream, archived
Headers show

Commit Message

Felipe Balbi May 21, 2010, 6:49 a.m. UTC
None
diff mbox

Patch

diff --git a/arch/arm/plat-omap/gpio.c b/arch/arm/plat-omap/gpio.c
index 95f92b0..ae03f6f 100644
--- a/arch/arm/plat-omap/gpio.c
+++ b/arch/arm/plat-omap/gpio.c
@@ -1855,6 +1855,7 @@  static int __init _omap_gpio_init(void)
                 bank->chip.get = gpio_get;
                 bank->chip.direction_output = gpio_output;
                 bank->chip.set_debounce = gpio_debounce;
+               bank->chip->flags = GPIO_FLAG_DEBOUNCE;
                 bank->chip.set = gpio_set;
                 bank->chip.to_irq = gpio_2irq;
                 if (bank_is_mpuio(bank)) {
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index cd85fd1..ed1ed74 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1461,9 +1461,14 @@  int gpio_set_debounce(unsigned gpio, unsigned debounce)
  
         spin_lock_irqsave(&gpio_lock, flags);
  
+       chip = desc->chip;
+       if (!(chip->flags & GPIO_FLAG_DEBOUNCE)) {
+               spin_unlock_irqrestore(&gpio_lock, flags);
+               return 0;
+       }
+
         if (!gpio_is_valid(gpio))
                 goto fail;
-       chip = desc->chip;
         if (!chip || !chip->set || !chip->set_debounce)
                 goto fail;
         gpio -= chip->base;
diff --git a/include/asm-generic/gpio.h b/include/asm-generic/gpio.h
index ce3eb87..26c0aa2 100644
--- a/include/asm-generic/gpio.h
+++ b/include/asm-generic/gpio.h
@@ -32,6 +32,8 @@  struct device;
  struct seq_file;
  struct module;
  
+#define GPIO_FLAG_DEBOUNCE     (1 << 0)
+
  /**
   * struct gpio_chip - abstract a GPIO controller
   * @label: for diagnostics
@@ -61,6 +63,7 @@  struct module;
   *      names for the GPIOs in this chip. Any entry in the array
   *      may be NULL if there is no alias for the GPIO, however the
   *      array must be @ngpio entries long.
+ * @flags: a bitmap for supported features by that particular gpio chip.
   *
   * A gpio_chip can help platforms abstract various sources of GPIOs so
   * they can all be accessed through a common programing interface.
@@ -104,6 +107,7 @@  struct gpio_chip {
         char                    **names;
         unsigned                can_sleep:1;
         unsigned                exported:1;
+       unsigned                flags;
  };
  
  extern const char *gpiochip_is_requested(struct gpio_chip *chip,