]> cvs.zerfleddert.de Git - ms2-fixes/blobdiff - debounce.c
helper for installing debug version
[ms2-fixes] / debounce.c
index be78a44777d86a7a1b1900a06823755a6cdb6feb..e6040167c3de8f2ccbbd9c1cb57405ca49aba6da 100644 (file)
@@ -33,15 +33,15 @@ static void hw_debounce_set(int enable, int time) {
        for (i = 0; i < gpio_evmi->ninputs; i++) {
                int gpio = gpio_evmi->input_gpios[i];
 
-               if (enable != -1) {
-                       printk(KERN_INFO PREFIX "%sabling hardware debounce for GPIO %d\n", (enable?"En":"Dis"), gpio);
-                       omap_set_gpio_debounce(gpio, enable);
-               }
-
-               if (time != -1) {
+               if ((time != -1) && (time != hw_debounce_time) && hw_debounce) {
                        printk(KERN_INFO PREFIX "Setting hardware debounce time for GPIO %d to %d (%dus)\n", gpio, time, (time+1)*31);
                        omap_set_gpio_debounce_time(gpio, time);
                }
+
+               if ((enable != -1) && (enable != hw_debounce)) {
+                       printk(KERN_INFO PREFIX "%sabling hardware debounce for GPIO %d\n", (enable?"En":"Dis"), gpio);
+                       omap_set_gpio_debounce(gpio, enable);
+               }
        }
 }
 
@@ -354,8 +354,10 @@ static ssize_t store_hw_debounce(struct device *dev, struct device_attribute *at
                hw_debounce = 1;
        }
        else {
+               hw_debounce_set(-1, 0);
                hw_debounce_set(0, -1);
                hw_debounce = 0;
+               hw_debounce_time = 0;
        }
 
        return count;
@@ -375,6 +377,9 @@ static ssize_t store_hw_debounce_time(struct device *dev, struct device_attribut
        if ((time < 0) || (time > 0xff))
                return count;
 
+       if (!hw_debounce)
+               return count;
+
        hw_debounce_set(-1, time);
        hw_debounce_time = time;
 
Impressum, Datenschutz