* [PATCH] Add suspend and resume to gpio_keys driver
@ 2007-09-06 15:38 Anti Sullin
2007-09-07 15:11 ` Dmitry Torokhov
0 siblings, 1 reply; 2+ messages in thread
From: Anti Sullin @ 2007-09-06 15:38 UTC (permalink / raw)
To: LKML
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] Add suspend and resume to gpio_keys driver
2007-09-06 15:38 [PATCH] Add suspend and resume to gpio_keys driver Anti Sullin
@ 2007-09-07 15:11 ` Dmitry Torokhov
0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Torokhov @ 2007-09-07 15:11 UTC (permalink / raw)
To: Anti Sullin; +Cc: LKML
Hi Anti,
On 9/6/07, Anti Sullin <anti.sullin@artecdesign.ee> wrote:
> 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);
I would expect platform code to mark devices as wakeup-able, wouldn't you agree?
--
Dmitry
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-09-07 15:11 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-09-06 15:38 [PATCH] Add suspend and resume to gpio_keys driver Anti Sullin
2007-09-07 15:11 ` Dmitry Torokhov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox