X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/blobdiff_plain/5df3a8e09f8ab9029a273b04aa8080dc23c1fee9..d3144a5e338d58010b06af1db9a3a9651328a869:/debounce.c diff --git a/debounce.c b/debounce.c index be78a44..e604016 100644 --- a/debounce.c +++ b/debounce.c @@ -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;