Messages in this thread Patch in this message | | | Date | Thu, 06 Sep 2007 18:38:31 +0300 | From | Anti Sullin <> | Subject | [PATCH] Add suspend and resume to gpio_keys driver |
| |
This patch adds suspend/resume support and enables wakeup from gpio_keys buttons.
Signed-off-by: Anti Sullin <anti.sullin@artecdesign.ee>
diff -pur linux-2.6.23-rc5-old/drivers/input/keyboard/gpio_keys.c linux-2.6.23-rc5/drivers/input/keyboard/gpio_keys.c --- linux-2.6.23-rc5-old/drivers/input/keyboard/gpio_keys.c 2007-09-06 18:24:23.000000000 +0300 +++ linux-2.6.23-rc5/drivers/input/keyboard/gpio_keys.c 2007-09-06 18:23:37.000000000 +0300 @@ -59,6 +59,7 @@ static int __devinit gpio_keys_probe(str if (!input) return -ENOMEM; + device_init_wakeup(&pdev->dev, 1); platform_set_drvdata(pdev, input); input->evbit[0] = BIT(EV_KEY); @@ -103,6 +104,7 @@ static int __devinit gpio_keys_probe(str free_irq(gpio_to_irq(pdata->buttons[i].gpio), pdev); input_free_device(input); + device_init_wakeup(&pdev->dev, 0); return error; } @@ -118,14 +120,51 @@ static int __devexit gpio_keys_remove(st free_irq(irq, pdev); } + device_init_wakeup(&pdev->dev, 0); input_unregister_device(input); return 0; } + +#ifdef CONFIG_PM +static int gpio_keys_suspend(struct platform_device *pdev, pm_message_t state) +{ + struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; + int i; + + if (device_may_wakeup(&pdev->dev)) { + for (i = 0; i < pdata->nbuttons; i++) { + int irq = gpio_to_irq(pdata->buttons[i].gpio); + enable_irq_wake(irq); + } + } + + return 0; +} + +static int gpio_keys_resume(struct platform_device *pdev) +{ + struct gpio_keys_platform_data *pdata = pdev->dev.platform_data; + int i; + + for (i = 0; i < pdata->nbuttons; i++) { + int irq = gpio_to_irq(pdata->buttons[i].gpio); + disable_irq_wake(irq); + } + + return 0; +} +#else +#define gpio_keys_suspend NULL +#define gpio_keys_resume NULL +#endif + struct platform_driver gpio_keys_device_driver = { .probe = gpio_keys_probe, .remove = __devexit_p(gpio_keys_remove), + .suspend = gpio_keys_suspend, + .resume = gpio_keys_resume, .driver = { .name = "gpio-keys", }
-- Anti Sullin Embedded Software Engineer Artec Design LLC Türi 10C, 11313, Tallinn, Estonia
- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |