From 57ffe9d539e0eb741bb9ca8f2834d210e70ee2e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 8 Aug 2008 12:14:34 -0400 Subject: Input: gpio-keys - optimize interrupt handler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/gpio_keys.c | 35 ++++++++++++----------------------- 1 file changed, 12 insertions(+), 23 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index be58730e636..e2809d29d99 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) static irqreturn_t gpio_keys_isr(int irq, void *dev_id) { - struct platform_device *pdev = dev_id; - struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; - struct gpio_keys_drvdata *ddata = platform_get_drvdata(pdev); - int i; + struct gpio_button_data *bdata = dev_id; + struct gpio_keys_button *button = bdata->button; - for (i = 0; i < pdata->nbuttons; i++) { - struct gpio_keys_button *button = &pdata->buttons[i]; + BUG_ON(irq != gpio_to_irq(button->gpio)); - if (irq == gpio_to_irq(button->gpio)) { - struct gpio_button_data *bdata = &ddata->data[i]; - - if (button->debounce_interval) - mod_timer(&bdata->timer, - jiffies + - msecs_to_jiffies(button->debounce_interval)); - else - gpio_keys_report_event(button, bdata->input); - - return IRQ_HANDLED; - } - } + if (button->debounce_interval) + mod_timer(&bdata->timer, + jiffies + msecs_to_jiffies(button->debounce_interval)); + else + gpio_keys_report_event(button, bdata->input); - return IRQ_NONE; + return IRQ_HANDLED; } static int __devinit gpio_keys_probe(struct platform_device *pdev) @@ -151,7 +140,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) IRQF_SAMPLE_RANDOM | IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING, button->desc ? button->desc : "gpio_keys", - pdev); + bdata); if (error) { pr_err("gpio-keys: Unable to claim irq %d; error %d\n", irq, error); @@ -178,7 +167,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev) fail2: while (--i >= 0) { - free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); + free_irq(gpio_to_irq(pdata->buttons[i].gpio), &ddata->data[i]); if (pdata->buttons[i].debounce_interval) del_timer_sync(&ddata->data[i].timer); gpio_free(pdata->buttons[i].gpio); @@ -203,7 +192,7 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev) for (i = 0; i < pdata->nbuttons; i++) { int irq = gpio_to_irq(pdata->buttons[i].gpio); - free_irq(irq, pdev); + free_irq(irq, &ddata->data[i]); if (pdata->buttons[i].debounce_interval) del_timer_sync(&ddata->data[i].timer); gpio_free(pdata->buttons[i].gpio); -- cgit v1.2.3 From ce25d7e90c7543f0046c3bdcdcc7594546c57dcc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Fri, 8 Aug 2008 12:14:36 -0400 Subject: Input: gpio-keys - simplify argument list for report_event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For now this only saves a few instructions (for gpio_keys_report_event, gpio_keys_isr and gpio_check_button one instraction each on ARM using arm-linux-gnu-gcc 4.2.3---I assume this is similar for other arch/compiler combinations). Signed-off-by: Uwe Kleine-König Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/gpio_keys.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c index e2809d29d99..fe22ca34d57 100644 --- a/drivers/input/keyboard/gpio_keys.c +++ b/drivers/input/keyboard/gpio_keys.c @@ -37,9 +37,10 @@ struct gpio_keys_drvdata { struct gpio_button_data data[0]; }; -static void gpio_keys_report_event(struct gpio_keys_button *button, - struct input_dev *input) +static void gpio_keys_report_event(struct gpio_button_data *bdata) { + struct gpio_keys_button *button = bdata->button; + struct input_dev *input = bdata->input; unsigned int type = button->type ?: EV_KEY; int state = (gpio_get_value(button->gpio) ? 1 : 0) ^ button->active_low; @@ -51,7 +52,7 @@ static void gpio_check_button(unsigned long _data) { struct gpio_button_data *data = (struct gpio_button_data *)_data; - gpio_keys_report_event(data->button, data->input); + gpio_keys_report_event(data); } static irqreturn_t gpio_keys_isr(int irq, void *dev_id) @@ -65,7 +66,7 @@ static irqreturn_t gpio_keys_isr(int irq, void *dev_id) mod_timer(&bdata->timer, jiffies + msecs_to_jiffies(button->debounce_interval)); else - gpio_keys_report_event(button, bdata->input); + gpio_keys_report_event(bdata); return IRQ_HANDLED; } -- cgit v1.2.3 From 160f1fef7e52e974489b3c70fbd4e094c06965c2 Mon Sep 17 00:00:00 2001 From: Joe Rouvier Date: Sun, 10 Aug 2008 00:29:25 -0400 Subject: Input: convert drivers to use strict_strtoul() strict_strtoul() allows newline character at the end of the the input string and therefore is more user-friendly. Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/atkbd.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index b1ce10f50bc..44745727aea 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -1207,15 +1207,13 @@ static ssize_t atkbd_set_extra(struct atkbd *atkbd, const char *buf, size_t coun { struct input_dev *old_dev, *new_dev; unsigned long value; - char *rest; int err; unsigned char old_extra, old_set; if (!atkbd->write) return -EIO; - value = simple_strtoul(buf, &rest, 10); - if (*rest || value > 1) + if (strict_strtoul(buf, 10, &value) || value > 1) return -EINVAL; if (atkbd->extra != value) { @@ -1264,12 +1262,10 @@ static ssize_t atkbd_set_scroll(struct atkbd *atkbd, const char *buf, size_t cou { struct input_dev *old_dev, *new_dev; unsigned long value; - char *rest; int err; unsigned char old_scroll; - value = simple_strtoul(buf, &rest, 10); - if (*rest || value > 1) + if (strict_strtoul(buf, 10, &value) || value > 1) return -EINVAL; if (atkbd->scroll != value) { @@ -1310,15 +1306,13 @@ static ssize_t atkbd_set_set(struct atkbd *atkbd, const char *buf, size_t count) { struct input_dev *old_dev, *new_dev; unsigned long value; - char *rest; int err; unsigned char old_set, old_extra; if (!atkbd->write) return -EIO; - value = simple_strtoul(buf, &rest, 10); - if (*rest || (value != 2 && value != 3)) + if (strict_strtoul(buf, 10, &value) || (value != 2 && value != 3)) return -EINVAL; if (atkbd->set != value) { @@ -1361,15 +1355,13 @@ static ssize_t atkbd_set_softrepeat(struct atkbd *atkbd, const char *buf, size_t { struct input_dev *old_dev, *new_dev; unsigned long value; - char *rest; int err; unsigned char old_softrepeat, old_softraw; if (!atkbd->write) return -EIO; - value = simple_strtoul(buf, &rest, 10); - if (*rest || value > 1) + if (strict_strtoul(buf, 10, &value) || value > 1) return -EINVAL; if (atkbd->softrepeat != value) { @@ -1413,12 +1405,10 @@ static ssize_t atkbd_set_softraw(struct atkbd *atkbd, const char *buf, size_t co { struct input_dev *old_dev, *new_dev; unsigned long value; - char *rest; int err; unsigned char old_softraw; - value = simple_strtoul(buf, &rest, 10); - if (*rest || value > 1) + if (strict_strtoul(buf, 10, &value) || value > 1) return -EINVAL; if (atkbd->softraw != value) { -- cgit v1.2.3 From 108fcb42c7bfd9ee205d1b8247813548705073b7 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Fri, 15 Aug 2008 13:53:08 -0400 Subject: Input: bf54x-keys - add power management support Fix Bug: does nor properply resume after suspend mem Fix for PM_SUSPEND_MEM: Save and restore peripheral base registers Signed-off-by: Michael Hennerich Signed-off-by: Bryan Wu Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/bf54x-keys.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/bf54x-keys.c b/drivers/input/keyboard/bf54x-keys.c index 54ed8e2e1c0..f1d20817ef2 100644 --- a/drivers/input/keyboard/bf54x-keys.c +++ b/drivers/input/keyboard/bf54x-keys.c @@ -8,7 +8,7 @@ * * * Modified: - * Copyright 2007 Analog Devices Inc. + * Copyright 2007-2008 Analog Devices Inc. * * Bugs: Enter bugs at http://blackfin.uclinux.org/ * @@ -82,6 +82,9 @@ struct bf54x_kpad { unsigned short *keycode; struct timer_list timer; unsigned int keyup_test_jiffies; + unsigned short kpad_msel; + unsigned short kpad_prescale; + unsigned short kpad_ctl; }; static inline int bfin_kpad_find_key(struct bf54x_kpad *bf54x_kpad, @@ -361,6 +364,10 @@ static int bfin_kpad_suspend(struct platform_device *pdev, pm_message_t state) { struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); + bf54x_kpad->kpad_msel = bfin_read_KPAD_MSEL(); + bf54x_kpad->kpad_prescale = bfin_read_KPAD_PRESCALE(); + bf54x_kpad->kpad_ctl = bfin_read_KPAD_CTL(); + if (device_may_wakeup(&pdev->dev)) enable_irq_wake(bf54x_kpad->irq); @@ -371,6 +378,10 @@ static int bfin_kpad_resume(struct platform_device *pdev) { struct bf54x_kpad *bf54x_kpad = platform_get_drvdata(pdev); + bfin_write_KPAD_MSEL(bf54x_kpad->kpad_msel); + bfin_write_KPAD_PRESCALE(bf54x_kpad->kpad_prescale); + bfin_write_KPAD_CTL(bf54x_kpad->kpad_ctl); + if (device_may_wakeup(&pdev->dev)) disable_irq_wake(bf54x_kpad->irq); -- cgit v1.2.3 From 61579ba83934d397a4fa2bb7372de9ae112587d5 Mon Sep 17 00:00:00 2001 From: Matthew Garrett Date: Fri, 15 Aug 2008 13:54:51 -0400 Subject: Input: atkbd - expand Latitude's force release quirk to other Dells Dell laptops fail to send key up events for several of their special keys. There's an existing quirk in the kernel to handle this, but it's limited to the Latitude range. This patch extends it to cover all portable Dells. Signed-off-by: Matthew Garrett Signed-off-by: Dmitry Torokhov --- drivers/input/keyboard/atkbd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'drivers/input/keyboard') diff --git a/drivers/input/keyboard/atkbd.c b/drivers/input/keyboard/atkbd.c index 44745727aea..22016ca1535 100644 --- a/drivers/input/keyboard/atkbd.c +++ b/drivers/input/keyboard/atkbd.c @@ -834,10 +834,10 @@ static void atkbd_disconnect(struct serio *serio) } /* - * Most special keys (Fn+F?) on Dell Latitudes do not generate release + * Most special keys (Fn+F?) on Dell laptops do not generate release * events so we have to do it ourselves. */ -static void atkbd_latitude_keymap_fixup(struct atkbd *atkbd) +static void atkbd_dell_laptop_keymap_fixup(struct atkbd *atkbd) { const unsigned int forced_release_keys[] = { 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b, 0x8f, 0x93, @@ -1451,13 +1451,13 @@ static int __init atkbd_setup_fixup(const struct dmi_system_id *id) static struct dmi_system_id atkbd_dmi_quirk_table[] __initdata = { { - .ident = "Dell Latitude series", + .ident = "Dell Laptop", .matches = { DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."), - DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"), + DMI_MATCH(DMI_CHASSIS_TYPE, "8"), /* Portable */ }, .callback = atkbd_setup_fixup, - .driver_data = atkbd_latitude_keymap_fixup, + .driver_data = atkbd_dell_laptop_keymap_fixup, }, { .ident = "HP 2133", -- cgit v1.2.3