aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input/keyboard/gpio_keys.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/input/keyboard/gpio_keys.c')
-rw-r--r--drivers/input/keyboard/gpio_keys.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index ccf6df387b62..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 }
@@ -63,8 +66,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
63 66
64 input->name = pdev->name; 67 input->name = pdev->name;
65 input->phys = "gpio-keys/input0"; 68 input->phys = "gpio-keys/input0";
66 input->cdev.dev = &pdev->dev; 69 input->dev.parent = &pdev->dev;
67 input->private = pdata;
68 70
69 input->id.bustype = BUS_HOST; 71 input->id.bustype = BUS_HOST;
70 input->id.vendor = 0x0001; 72 input->id.vendor = 0x0001;
@@ -72,19 +74,21 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
72 input->id.version = 0x0100; 74 input->id.version = 0x0100;
73 75
74 for (i = 0; i < pdata->nbuttons; i++) { 76 for (i = 0; i < pdata->nbuttons; i++) {
75 int code = pdata->buttons[i].keycode; 77 struct gpio_keys_button *button = &pdata->buttons[i];
76 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;
77 80
78 set_irq_type(irq, IRQ_TYPE_EDGE_BOTH); 81 set_irq_type(irq, IRQ_TYPE_EDGE_BOTH);
79 error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM, 82 error = request_irq(irq, gpio_keys_isr, IRQF_SAMPLE_RANDOM,
80 pdata->buttons[i].desc ? pdata->buttons[i].desc : "gpio_keys", 83 button->desc ? button->desc : "gpio_keys",
81 pdev); 84 pdev);
82 if (error) { 85 if (error) {
83 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",
84 irq, error); 87 irq, error);
85 goto fail; 88 goto fail;
86 } 89 }
87 set_bit(code, input->keybit); 90
91 input_set_capability(input, type, button->code);
88 } 92 }
89 93
90 error = input_register_device(input); 94 error = input_register_device(input);