All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anti Sullin <anti.sullin@artecdesign.ee>
To: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] Add suspend and resume to gpio_keys driver
Date: Thu, 06 Sep 2007 18:38:31 +0300	[thread overview]
Message-ID: <46E01EF7.7010605@artecdesign.ee> (raw)

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


             reply	other threads:[~2007-09-06 16:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-09-06 15:38 Anti Sullin [this message]
2007-09-07 15:11 ` [PATCH] Add suspend and resume to gpio_keys driver Dmitry Torokhov

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=46E01EF7.7010605@artecdesign.ee \
    --to=anti.sullin@artecdesign.ee \
    --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.