aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/input
diff options
context:
space:
mode:
authorUwe Kleine-König <Uwe.Kleine-Koenig@digi.com>2008-08-08 12:14:34 -0400
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2008-08-08 12:20:12 -0400
commit57ffe9d539e0eb741bb9ca8f2834d210e70ee2e3 (patch)
treebd058b8c02fe76a501fbf59085760ebf421f6797 /drivers/input
parent34a7c48c221676ff8322ca4b8ded84eada34cf12 (diff)
Input: gpio-keys - optimize interrupt handler
By passing a gpio_button_data structure to the handler instead of the whole platform_device the search for the right button can go away. Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig@digi.com> Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
Diffstat (limited to 'drivers/input')
-rw-r--r--drivers/input/keyboard/gpio_keys.c35
1 files changed, 12 insertions, 23 deletions
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index be58730e636a..e2809d29d99d 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -56,29 +56,18 @@ static void gpio_check_button(unsigned long _data)
56 56
57static irqreturn_t gpio_keys_isr(int irq, void *dev_id) 57static irqreturn_t gpio_keys_isr(int irq, void *dev_id)
58{ 58{
59 struct platform_device *pdev = dev_id; 59 struct gpio_button_data *bdata = dev_id;
60 struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; 60 struct gpio_keys_button *button = bdata->button;
61 struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev);
62 int i;
63 61
64 for (i = 0; i < pdata->nbuttons; i++) { 62 BUG_ON(irq != gpio_to_irq(button->gpio));
65 struct gpio_keys_button *button = &pdata->buttons[i];
66 63
67 if (irq == gpio_to_irq(button->gpio)) { 64 if (button->debounce_interval)
68 struct gpio_button_data *bdata = &ddata->data[i]; 65 mod_timer(&bdata->timer,
69 66 jiffies + msecs_to_jiffies(button->debounce_interval));
70 if (button->debounce_interval) 67 else
71 mod_timer(&bdata->timer, 68 gpio_keys_report_event(button, bdata->input);
72 jiffies +
73 msecs_to_jiffies(button->debounce_interval));
74 else
75 gpio_keys_report_event(button, bdata->input);
76
77 return IRQ_HANDLED;
78 }
79 }
80 69
81 return IRQ_NONE; 70 return IRQ_HANDLED;
82} 71}
83 72
84static int __devinit gpio_keys_probe(struct platform_device *pdev) 73static int __devinit gpio_keys_probe(struct platform_device *pdev)
@@ -151,7 +140,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
151 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | 140 IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING |
152 IRQF_TRIGGER_FALLING, 141 IRQF_TRIGGER_FALLING,
153 button->desc ? button->desc : "gpio_keys", 142 button->desc ? button->desc : "gpio_keys",
154 pdev); 143 bdata);
155 if (error) { 144 if (error) {
156 pr_err("gpio-keys: Unable to claim irq %d; error %d\n", 145 pr_err("gpio-keys: Unable to claim irq %d; error %d\n",
157 irq, error); 146 irq, error);
@@ -178,7 +167,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
178 167
179 fail2: 168 fail2:
180 while (--i >= 0) { 169 while (--i >= 0) {
181 free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); 170 free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]);
182 if (pdata->buttons[i].debounce_interval) 171 if (pdata->buttons[i].debounce_interval)
183 del_timer_sync(&ddata->data[i].timer); 172 del_timer_sync(&ddata->data[i].timer);
184 gpio_free(pdata->buttons[i].gpio); 173 gpio_free(pdata->buttons[i].gpio);
@@ -203,7 +192,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
203 192
204 for (i = 0; i < pdata->nbuttons; i++) { 193 for (i = 0; i < pdata->nbuttons; i++) {
205 int irq = gpio_to_irq(pdata->buttons[i].gpio); 194 int irq = gpio_to_irq(pdata->buttons[i].gpio);
206 free_irq(irq, pdev); 195 free_irq(irq, &ddata->data[i]);
207 if (pdata->buttons[i].debounce_interval) 196 if (pdata->buttons[i].debounce_interval)
208 del_timer_sync(&ddata->data[i].timer); 197 del_timer_sync(&ddata->data[i].timer);
209 gpio_free(pdata->buttons[i].gpio); 198 gpio_free(pdata->buttons[i].gpio);