X-Git-Url: https://git.zerfleddert.de/cgi-bin/gitweb.cgi/ms2-fixes/blobdiff_plain/29bad272e177a379197aebf1bfeef080da12b86f..8440ec7c4b58305b60157d0ce8ae0260ed880bca:/debounce.c diff --git a/debounce.c b/debounce.c index 3176d4c..e604016 100644 --- a/debounce.c +++ b/debounce.c @@ -33,14 +33,14 @@ 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) && (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 (time != -1) { - printk(KERN_INFO PREFIX "Setting hardware debounce itime 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;