diff options
Diffstat (limited to 'drivers/input/keyboard/gpio_keys.c')
-rw-r--r-- | drivers/input/keyboard/gpio_keys.c | 42 |
1 files changed, 16 insertions, 26 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index ec96b369dd7..05f3f43582c 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c | |||
@@ -36,9 +36,10 @@ struct gpio_keys_drvdata { | |||
36 | struct gpio_button_data data[0]; | 36 | struct gpio_button_data data[0]; |
37 | }; | 37 | }; |
38 | 38 | ||
39 | static void gpio_keys_report_event(struct gpio_keys_button *button, | 39 | static void gpio_keys_report_event(struct gpio_button_data *bdata) |
40 | struct input_dev *input) | ||
41 | { | 40 | { |
41 | struct gpio_keys_button *button = bdata->button; | ||
42 | struct input_dev *input = bdata->input; | ||
42 | unsigned int type = button->type ?: EV_KEY; | 43 | unsigned int type = button->type ?: EV_KEY; |
43 | int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; | 44 | int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; |
44 | 45 | ||
@@ -50,34 +51,23 @@ static void gpio_check_button(unsigned long _data) | |||
50 | { | 51 | { |
51 | struct gpio_button_data *data = (struct gpio_button_data *)_data; | 52 | struct gpio_button_data *data = (struct gpio_button_data *)_data; |
52 | 53 | ||
53 | gpio_keys_report_event(data->button, data->input); | 54 | gpio_keys_report_event(data); |
54 | } | 55 | } |
55 | 56 | ||
56 | static irqreturn_t gpio_keys_isr(int irq, void *dev_id) | 57 | static irqreturn_t gpio_keys_isr(int irq, void *dev_id) |
57 | { | 58 | { |
58 | struct platform_device *pdev = dev_id; | 59 | struct gpio_button_data *bdata = dev_id; |
59 | struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; | 60 | struct gpio_keys_button *button = bdata->button; |
60 | struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); | ||
61 | int i; | ||
62 | 61 | ||
63 | for (i = 0; i < pdata->nbuttons; i++) { | 62 | BUG_ON(irq != gpio_to_irq(button->gpio)); |
64 | struct gpio_keys_button *button = &pdata->buttons[i]; | ||
65 | 63 | ||
66 | if (irq == gpio_to_irq(button->gpio)) { | 64 | if (button->debounce_interval) |
67 | struct gpio_button_data *bdata = &ddata->data[i]; | 65 | mod_timer(&bdata->timer, |
68 | 66 | jiffies + msecs_to_jiffies(button->debounce_interval)); | |
69 | if (button->debounce_interval) | 67 | else |
70 | mod_timer(&bdata->timer, | 68 | gpio_keys_report_event(bdata); |
71 | jiffies + | ||
72 | msecs_to_jiffies(button->debounce_interval)); | ||
73 | else | ||
74 | gpio_keys_report_event(button, bdata->input); | ||
75 | |||
76 | return IRQ_HANDLED; | ||
77 | } | ||
78 | } | ||
79 | 69 | ||
80 | return IRQ_NONE; | 70 | return IRQ_HANDLED; |
81 | } | 71 | } |
82 | 72 | ||
83 | static int __devinit gpio_keys_probe(struct platform_device *pdev) | 73 | static int __devinit gpio_keys_probe(struct platform_device *pdev) |
@@ -151,7 +141,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
151 | IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | | 141 | IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | |
152 | IRQF_TRIGGER_FALLING, | 142 | IRQF_TRIGGER_FALLING, |
153 | button->desc ? button->desc : "gpio_keys", | 143 | button->desc ? button->desc : "gpio_keys", |
154 | pdev); | 144 | bdata); |
155 | if (error) { | 145 | if (error) { |
156 | pr_err("gpio-keys: Unable to claim irq %d; error %d\n", | 146 | pr_err("gpio-keys: Unable to claim irq %d; error %d\n", |
157 | irq, error); | 147 | irq, error); |
@@ -178,7 +168,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) | |||
178 | 168 | ||
179 | fail2: | 169 | fail2: |
180 | while (--i >= 0) { | 170 | while (--i >= 0) { |
181 | free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); | 171 | free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); |
182 | if (pdata->buttons[i].debounce_interval) | 172 | if (pdata->buttons[i].debounce_interval) |
183 | del_timer_sync(&ddata->data[i].timer); | 173 | del_timer_sync(&ddata->data[i].timer); |
184 | gpio_free(pdata->buttons[i].gpio); | 174 | gpio_free(pdata->buttons[i].gpio); |
@@ -203,7 +193,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) | |||
203 | 193 | ||
204 | for (i = 0; i < pdata->nbuttons; i++) { | 194 | for (i = 0; i < pdata->nbuttons; i++) { |
205 | int irq = gpio_to_irq(pdata->buttons[i].gpio); | 195 | int irq = gpio_to_irq(pdata->buttons[i].gpio); |
206 | free_irq(irq, pdev); | 196 | free_irq(irq, &ddata->data[i]); |
207 | if (pdata->buttons[i].debounce_interval) | 197 | if (pdata->buttons[i].debounce_interval) |
208 | del_timer_sync(&ddata->data[i].timer); | 198 | del_timer_sync(&ddata->data[i].timer); |
209 | gpio_free(pdata->buttons[i].gpio); | 199 | gpio_free(pdata->buttons[i].gpio); |