+ add-suspend-and-resume-to-gpio_keys-driver.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Add suspend and resume to gpio_keys driver
has been added to the -mm tree.  Its filename is
     add-suspend-and-resume-to-gpio_keys-driver.patch

*** Remember to use Documentation/SubmitChecklist when testing your code ***

See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find
out what to do about this

------------------------------------------------------
Subject: Add suspend and resume to gpio_keys driver
From: Anti Sullin <anti.sullin@xxxxxxxxxxxxxx>

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@xxxxxxxxxxxxxx>
Cc: Dmitry Torokhov <dtor@xxxxxxx>
Cc: David Brownell <david-b@xxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 drivers/input/keyboard/gpio_keys.c |   44 +++++++++++++++++++++++++++
 include/linux/gpio_keys.h          |    1 
 2 files changed, 45 insertions(+)

diff -puN drivers/input/keyboard/gpio_keys.c~add-suspend-and-resume-to-gpio_keys-driver drivers/input/keyboard/gpio_keys.c
--- a/drivers/input/keyboard/gpio_keys.c~add-suspend-and-resume-to-gpio_keys-driver
+++ a/drivers/input/keyboard/gpio_keys.c
@@ -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 -puN include/linux/gpio_keys.h~add-suspend-and-resume-to-gpio_keys-driver include/linux/gpio_keys.h
--- a/include/linux/gpio_keys.h~add-suspend-and-resume-to-gpio_keys-driver
+++ a/include/linux/gpio_keys.h
@@ -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 {
_

Patches currently in -mm which might be from anti.sullin@xxxxxxxxxxxxxx are

bug-in-at91-mci-suspend-routines.patch
add-suspend-and-resume-to-gpio_keys-driver.patch

-
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Kernel Newbies FAQ]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Photo]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux