]>
git.zerfleddert.de Git - ms2-fixes/blob - debounce.c
7489f8cb535164b7ed25026699fefd56ad211dde
1 #include <linux/module.h>
2 #include <linux/device.h>
3 #include <linux/platform_device.h>
4 #include <linux/gpio_event.h>
6 int find_ms2_dev(struct device
*dev
, void *data
)
8 if (!strncmp((char*)data
, dev_name(dev
), strlen((char*)data
))) {
9 printk(KERN_INFO
"Found it!\n");
15 static int __init
debounce_init(void)
17 struct device
*event_dev
= NULL
;
18 struct gpio_event_platform_data
*gpio_epd
;
19 struct gpio_event_info
*gpio_ei
;
20 struct gpio_event_matrix_info
*gpio_evmi
;
22 printk(KERN_INFO
"Searching for " GPIO_EVENT_DEV_NAME
"...\n");
25 event_dev
= device_find_child(&platform_bus
, GPIO_EVENT_DEV_NAME
, find_ms2_dev
);
26 if (event_dev
== NULL
)
29 gpio_epd
= (struct gpio_event_platform_data
*)event_dev
->platform_data
;
30 printk(KERN_INFO
"And there is a %s connected...\n", gpio_epd
->name
);
31 if (strcmp(gpio_epd
->name
, "sholes-keypad"))
34 gpio_ei
= (struct gpio_event_info
*)gpio_epd
->info
[0];
35 gpio_evmi
= container_of(gpio_ei
, struct gpio_event_matrix_info
, info
);
37 printk(KERN_INFO
"settle_time: %u\n", gpio_evmi
->settle_time
.tv
.nsec
);
38 printk(KERN_INFO
"poll_time: %u\n", gpio_evmi
->poll_time
.tv
.nsec
);
39 printk(KERN_INFO
"debounce_delay: %u\n", gpio_evmi
->debounce_delay
.tv
.nsec
);
40 printk(KERN_INFO
"flags: %x\n", gpio_evmi
->flags
);
41 if (!gpio_evmi
->debounce_delay
.tv
.nsec
) {
42 printk(KERN_INFO
"Activating debounce!\n");
43 gpio_evmi
->debounce_delay
.tv
.nsec
= 5 * NSEC_PER_MSEC
;
45 /* GPIOKPF_DEBOUNCE should already be set by GPIOKPF_REMOVE_PHANTOM_KEYS */
46 gpio_evmi
->flags
|= GPIOKPF_DEBOUNCE
;
47 printk(KERN_INFO
"debounce_delay: %u\n", gpio_evmi
->debounce_delay
.tv
.nsec
);
48 printk(KERN_INFO
"flags: %x\n", gpio_evmi
->flags
);
54 static void __exit
debounce_exit(void)
58 module_init(debounce_init
);
59 module_exit(debounce_exit
);
61 MODULE_LICENSE("GPL");
62 MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");