From: Anti Sullin <anti.sullin@artecdesign.ee>
To: LKML <linux-kernel@vger.kernel.org>
Cc: dmitry.torokhov@gmail.com
Subject: [PATCH][resend] Add suspend and resume to gpio_keys driver
Date: Mon, 10 Sep 2007 10:51:08 +0300 [thread overview]
Message-ID: <46E4F76C.6080004@artecdesign.ee> (raw)
This patch adds suspend/resume support and enables wakeup from gpio_keys
buttons. Buttons, that generate wakeup events, can be specified in
platform data.
Signed-off-by: Anti Sullin <anti.sullin@artecdesign.ee>
diff -pur linux-2.6.23-rc5-clean/drivers/input/keyboard/gpio_keys.c
linux-2.6.23-rc5/drivers/input/keyboard/gpio_keys.c
--- linux-2.6.23-rc5-clean/drivers/input/keyboard/gpio_keys.c
2007-09-10 09:52:18.000000000 +0300
+++ linux-2.6.23-rc5/drivers/input/keyboard/gpio_keys.c 2007-09-10
10:01:56.000000000 +0300
@@ -54,6 +54,7 @@ static int __devinit gpio_keys_probe(str
struct gpio_keys_platform_data *pdata = pdev->dev.platform_data;
struct input_dev *input;
int i, error;
+ int wakeup = 0;
input = input_allocate_device();
if (!input)
@@ -87,6 +88,9 @@ static int __devinit gpio_keys_probe(str
goto fail;
}
+ if (button->wakeup)
+ wakeup = 1;
+
input_set_capability(input, type, button->code);
}
@@ -96,6 +100,8 @@ static int __devinit gpio_keys_probe(str
goto fail;
}
+ device_init_wakeup(&pdev->dev, wakeup);
+
return 0;
fail:
@@ -118,14 +124,52 @@ 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);
+ if (pdata->buttons[i].wakeup)
+ 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",
}
diff -pur linux-2.6.23-rc5-clean/include/linux/gpio_keys.h
linux-2.6.23-rc5/include/linux/gpio_keys.h
--- linux-2.6.23-rc5-clean/include/linux/gpio_keys.h 2007-09-01
09:08:24.000000000 +0300
+++ linux-2.6.23-rc5/include/linux/gpio_keys.h 2007-09-10
10:43:39.000000000 +0300
@@ -8,6 +8,7 @@ struct gpio_keys_button {
int active_low;
char *desc;
int type; /* input event type (EV_KEY, EV_SW) */
+ int wakeup; /* configure the button as wake-up source from
suspend */
};
struct gpio_keys_platform_data {
reply other threads:[~2007-09-10 7:51 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=46E4F76C.6080004@artecdesign.ee \
--to=anti.sullin@artecdesign.ee \
--cc=dmitry.torokhov@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.