aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard
diff options
context:
space:
mode:
authorRoman Moravcik <roman.moravcik@gmail.com>2007-05-01 00:39:13 -0400
committerDmitry Torokhov <dtor@insightbb.com>2007-05-01 00:39:13 -0400
commit84767d00a8fd54dd97866561f6e2ee246c8e1cdc (patch)
tree230e23cb988b86a6c81736a7915ed733771ad990 /drivers/input/keyboard
parentbc95f3669f5e6f63cf0b84fe4922c3c6dd4aa775 (diff)
Input: gpio_keys - add support for switches (EV_SW)
Signed-off-by: Roman Moravcik <roman.moravcik@gmail.com> Signed-off-by: Paul Sokolovsky <pmiscml@gmail.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input/keyboard')
-rw-r--r--drivers/input/keyboard/gpio_keys.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 0d2796cdf738..739212252b09 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -35,11 +35,14 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
35 struct input_dev *input = platform_get_drvdata(pdev); 35 struct input_dev *input = platform_get_drvdata(pdev);
36 36
37 for (i = 0; i < pdata->nbuttons; i++) { 37 for (i = 0; i < pdata->nbuttons; i++) {
38 int gpio = pdata->buttons[i].gpio; 38 struct gpio_keys_button *button = &pdata->buttons[i];
39 int gpio = button->gpio;
40
39 if (irq == gpio_to_irq(gpio)) { 41 if (irq == gpio_to_irq(gpio)) {
40 int state = (gpio_get_value(gpio) ? 1 : 0) ^ (pdata->buttons[i].active_low); 42 unsigned int type = button->type ?: EV_KEY;
43 int state = (gpio_get_value(gpio) ? 1 : 0) ^ button->active_low;
41 44
42 input_report_key(input, pdata->buttons[i].keycode, state); 45 input_event(input, type, button->code, !!state);
43 input_sync(input); 46 input_sync(input);
44 } 47 }
45 } 48 }
@@ -71,19 +74,21 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
71 input->id.version = 0x0100; 74 input->id.version = 0x0100;
72 75
73 for (i = 0; i < pdata->nbuttons; i++) { 76 for (i = 0; i < pdata->nbuttons; i++) {
74 int code = pdata->buttons[i].keycode; 77 struct gpio_keys_button *button = &pdata->buttons[i];
75 int irq = gpio_to_irq(pdata->buttons[i].gpio); 78 int irq = gpio_to_irq(button->gpio);
79 unsigned int type = button->type ?: EV_KEY;
76 80
77 set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); 81 set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
78 error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM, 82 error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM,
79 pdata->buttons[i].desc ? pdata->buttons[i].desc : "gpio_keys", 83 button->desc ? button->desc : "gpio_keys",
80 pdev); 84 pdev);
81 if (error) { 85 if (error) {
82 printk(KERN_ERR "gpio-keys: unable to claim irq %d; error %d\n", 86 printk(KERN_ERR "gpio-keys: unable to claim irq %d; error %d\n",
83 irq, error); 87 irq, error);
84 goto fail; 88 goto fail;
85 } 89 }
86 set_bit(code, input->keybit); 90
91 input_set_capability(input, type, button->code);
87 } 92 }
88 93
89 error = input_register_device(input); 94 error = input_register_device(input);