add README (based on xda post)
[ms2-fixes] / debounce.c
CommitLineData
b422e333 1#include <linux/module.h>
d1ff9643
MG
2#include <linux/device.h>
3#include <linux/platform_device.h>
4#include <linux/gpio_event.h>
5
6int 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}
b422e333
MG
14
15static int __init debounce_init(void)
16{
d1ff9643
MG
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 if (!gpio_evmi->debounce_delay.tv.nsec) {
41 printk(KERN_INFO "Activating debounce!\n");
42 gpio_evmi->debounce_delay.tv.nsec = 5 * NSEC_PER_MSEC;
43 printk(KERN_INFO "debounce_delay: %u\n", gpio_evmi->debounce_delay.tv.nsec);
44 }
45
b422e333
MG
46 return 0;
47}
48
49static void __exit debounce_exit(void)
50{
51}
52
53module_init(debounce_init);
54module_exit(debounce_exit);
55
56MODULE_LICENSE("GPL");
57MODULE_AUTHOR("Michael Gernoth <michael@gernoth.net>");
Impressum, Datenschutz