]> git.zerfleddert.de Git - ms2-fixes/blob - debounce.c
7489f8cb535164b7ed25026699fefd56ad211dde
[ms2-fixes] / debounce.c
1 #include <linux/module.h>
2 #include <linux/device.h>
3 #include <linux/platform_device.h>
4 #include <linux/gpio_event.h>
5
6 int find_ms2_dev(struct device *dev, void *data)
7 {
8 if (!strncmp((char*)data, dev_name(dev), strlen((char*)data))) {
9 printk(KERN_INFO "Found it!\n");
10 return 1;
11 }
12 return 0;
13 }
14
15 static int __init debounce_init(void)
16 {
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;
21
22 printk(KERN_INFO "Searching for " GPIO_EVENT_DEV_NAME "...\n");
23
24
25 event_dev = device_find_child(&platform_bus, GPIO_EVENT_DEV_NAME, find_ms2_dev);
26 if (event_dev == NULL)
27 return -ENODEV;
28
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"))
32 return -ENODEV;
33
34 gpio_ei = (struct gpio_event_info*)gpio_epd->info[0];
35 gpio_evmi = container_of(gpio_ei, struct gpio_event_matrix_info, info);
36
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;
44
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);
49 }
50
51 return 0;
52 }
53
54 static void __exit debounce_exit(void)
55 {
56 }
57
58 module_init(debounce_init);
59 module_exit(debounce_exit);
60
61 MODULE_LICENSE("GPL");
62 MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");
Impressum, Datenschutz