restore old state when unloading module
authorMichael Gernoth <michael@gernoth.net>
Sat, 21 May 2011 16:46:46 +0000 (18:46 +0200)
committerMichael Gernoth <michael@gernoth.net>
Sat, 21 May 2011 16:46:46 +0000 (18:46 +0200)
MS2Debounce/assets/debounce.ko
debounce.c

index cb1a584ee3919ff142ee23517913e02cdd2a8e02..06a947d8e5d3a0f041acf11d8d4afb6e9ed3b685 100644 (file)
Binary files a/MS2Debounce/assets/debounce.ko and b/MS2Debounce/assets/debounce.ko differ
index 845adad4cd2d174ac0d3f609f0898f0f05e4ee1f..4006cd2a4c81310e4aa1efa0f3adcd8b4642fc78 100644 (file)
@@ -7,6 +7,9 @@
 
 static int debounce_delay = 10;
 
+static int old_delay = 0;
+static struct gpio_event_matrix_info *gpio_evmi = NULL;
+
 module_param(debounce_delay, int, S_IRUSR | S_IRGRP | S_IROTH);
 MODULE_PARM_DESC(debounce_delay, "debouncing delay (ms), default: 10");
 
@@ -24,7 +27,6 @@ static int __init debounce_init(void)
        struct device *event_dev = NULL;
        struct gpio_event_platform_data *gpio_epd;
        struct gpio_event_info *gpio_ei;
-       struct gpio_event_matrix_info *gpio_evmi;
 
        printk(KERN_INFO PREFIX "Searching for " GPIO_EVENT_DEV_NAME "...\n");
 
@@ -53,6 +55,8 @@ static int __init debounce_init(void)
                printk(KERN_INFO PREFIX "flags: 0x%x\n", gpio_evmi->flags);
        }
 
+       old_delay = gpio_evmi->debounce_delay.tv.nsec;
+
        if (gpio_evmi->debounce_delay.tv.nsec != debounce_delay * NSEC_PER_MSEC) {
                printk(KERN_INFO PREFIX "Changing debounce_delay\n");
                gpio_evmi->debounce_delay.tv.nsec = debounce_delay * NSEC_PER_MSEC;
@@ -64,6 +68,13 @@ static int __init debounce_init(void)
 
 static void __exit debounce_exit(void)
 {
+       if (gpio_evmi) {
+               if (gpio_evmi->debounce_delay.tv.nsec != old_delay) {
+                       printk(KERN_INFO PREFIX "Restoring debounce_delay\n");
+                       gpio_evmi->debounce_delay.tv.nsec = old_delay;
+                       printk(KERN_INFO PREFIX "debounce_delay: %u\n", gpio_evmi->debounce_delay.tv.nsec);
+               }
+       }
 }
 
 module_init(debounce_init);
Impressum, Datenschutz