[PATCH 1/2] input: gpio-keys: Disable hardware on suspend

Subsystems: input (keyboard, mouse, joystick, touchscreen) drivers, the rest

STALE5065d REVIEWED: 2 (0M)

2 review trailers.

11 messages, 4 authors, 2012-10-25 · open the first message on its own page

[PATCH 1/2] input: gpio-keys: Disable hardware on suspend

From: Lee Jones <hidden>
Date: 2012-10-11 14:15:47

From: Jonas Aaberg <redacted>

Disable hardware if active when suspending if the hw can not
wake the system from suspend.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Lee Jones <redacted>
Signed-off-by: Jonas Aaberg <redacted>
Signed-off-by: Philippe Langlais <redacted>
Reviewed-by: Bengt Jonsson <redacted>
---
 drivers/input/keyboard/gpio_keys.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index cbb1add..7947315 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -46,6 +46,8 @@ struct gpio_keys_drvdata {
 	struct input_dev *input;
 	struct mutex disable_lock;
 	unsigned int n_buttons;
+	bool enabled;
+	bool enable_after_suspend;
 	int (*enable)(struct device *dev);
 	void (*disable)(struct device *dev);
 	struct gpio_button_data data[0];
@@ -524,6 +526,7 @@ static int gpio_keys_open(struct input_dev *input)
 {
 	struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
 
+	ddata->enabled = true;
 	return ddata->enable ? ddata->enable(input->dev.parent) : 0;
 }
 
@@ -533,6 +536,7 @@ static void gpio_keys_close(struct input_dev *input)
 
 	if (ddata->disable)
 		ddata->disable(input->dev.parent);
+	ddata->enabled = false;
 }
 
 /*
@@ -674,6 +678,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 	ddata->n_buttons = pdata->nbuttons;
 	ddata->enable = pdata->enable;
 	ddata->disable = pdata->disable;
+	ddata->enabled = false;
 	mutex_init(&ddata->disable_lock);
 
 	platform_set_drvdata(pdev, ddata);
@@ -789,6 +794,10 @@ static int gpio_keys_suspend(struct device *dev)
 			if (bdata->button->wakeup)
 				enable_irq_wake(bdata->irq);
 		}
+	} else {
+		ddata->enable_after_suspend = ddata->enabled;
+		if (ddata->enabled)
+			gpio_keys_close(ddata->input);
 	}
 
 	return 0;
@@ -807,6 +816,10 @@ static int gpio_keys_resume(struct device *dev)
 		if (gpio_is_valid(bdata->button->gpio))
 			gpio_keys_gpio_report_event(bdata);
 	}
+
+	if (!device_may_wakeup(dev) && ddata->enable_after_suspend)
+		gpio_keys_open(ddata->input);
+
 	input_sync(ddata->input);
 
 	return 0;
-- 
1.7.9.5

[PATCH 2/2] input: gpio-keys: Add runtime support

From: Lee Jones <hidden>
Date: 2012-10-11 14:15:56

From: Jonas Aaberg <redacted>

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Lee Jones <redacted>
Signed-off-by: Jonas Aaberg <redacted>
Signed-off-by: Philippe Langlais <redacted>
Reviewed-by: Bengt Jonsson <redacted>
---
 drivers/input/keyboard/gpio_keys.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 7947315..78de557 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -29,6 +29,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/spinlock.h>
+#include <linux/pm_runtime.h>
 
 struct gpio_button_data {
 	const struct gpio_keys_button *button;
@@ -526,6 +527,7 @@ static int gpio_keys_open(struct input_dev *input)
 {
 	struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
 
+	pm_runtime_get_sync(input->dev.parent);
 	ddata->enabled = true;
 	return ddata->enable ? ddata->enable(input->dev.parent) : 0;
 }
@@ -537,6 +539,7 @@ static void gpio_keys_close(struct input_dev *input)
 	if (ddata->disable)
 		ddata->disable(input->dev.parent);
 	ddata->enabled = false;
+	pm_runtime_put(input->dev.parent);
 }
 
 /*
@@ -695,6 +698,8 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 	input->id.product = 0x0001;
 	input->id.version = 0x0100;
 
+	pm_runtime_enable(&pdev->dev);
+
 	/* Enable auto repeat feature of Linux input subsystem */
 	if (pdata->rep)
 		__set_bit(EV_REP, input->evbit);
@@ -760,6 +765,8 @@ static int __devexit gpio_keys_remove(struct platform_device *pdev)
 	struct input_dev *input = ddata->input;
 	int i;
 
+	pm_runtime_disable(&pdev->dev);
+
 	sysfs_remove_group(&pdev->dev.kobj, &gpio_keys_attr_group);
 
 	device_init_wakeup(&pdev->dev, 0);
@@ -796,8 +803,8 @@ static int gpio_keys_suspend(struct device *dev)
 		}
 	} else {
 		ddata->enable_after_suspend = ddata->enabled;
-		if (ddata->enabled)
-			gpio_keys_close(ddata->input);
+		if (ddata->enabled && ddata->disable)
+			ddata->disable(dev);
 	}
 
 	return 0;
@@ -817,8 +824,9 @@ static int gpio_keys_resume(struct device *dev)
 			gpio_keys_gpio_report_event(bdata);
 	}
 
-	if (!device_may_wakeup(dev) && ddata->enable_after_suspend)
-		gpio_keys_open(ddata->input);
+	if (!device_may_wakeup(dev) && ddata->enable_after_suspend
+	    && ddata->enable)
+		ddata->enable(dev);
 
 	input_sync(ddata->input);
 
-- 
1.7.9.5

Re: [PATCH 2/2] input: gpio-keys: Add runtime support

From: Shubhrajyoti Datta <hidden>
Date: 2012-10-11 14:22:14

On Thu, Oct 11, 2012 at 7:45 PM, Lee Jones [off-list ref] wrote:
From: Jonas Aaberg <redacted>
Some change logs would have helped.
quoted hunk
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Lee Jones <redacted>
Signed-off-by: Jonas Aaberg <redacted>
Signed-off-by: Philippe Langlais <redacted>
Reviewed-by: Bengt Jonsson <redacted>
---
 drivers/input/keyboard/gpio_keys.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 7947315..78de557 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -29,6 +29,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/spinlock.h>
+#include <linux/pm_runtime.h>

 struct gpio_button_data {
        const struct gpio_keys_button *button;
@@ -526,6 +527,7 @@ static int gpio_keys_open(struct input_dev *input)
 {
        struct gpio_keys_drvdata *ddata = input_get_drvdata(input);

+       pm_runtime_get_sync(input->dev.parent);
I am not an expert of the runtime.

However would be grateful if you explain me what it actually do.

Also I did not see any runtime suspend/ resume handlers populated.

Re: [PATCH 2/2] input: gpio-keys: Add runtime support

From: Lee Jones <hidden>
Date: 2012-10-11 15:21:37

quoted
From: Jonas Aaberg <redacted>
Some change logs would have helped.
Granted.

Hopefully Jonas will be happy to step forward and answer any of
your following questions.
quoted
Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Lee Jones <redacted>
Signed-off-by: Jonas Aaberg <redacted>
Signed-off-by: Philippe Langlais <redacted>
Reviewed-by: Bengt Jonsson <redacted>
---
 drivers/input/keyboard/gpio_keys.c |   16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index 7947315..78de557 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -29,6 +29,7 @@
 #include <linux/of_platform.h>
 #include <linux/of_gpio.h>
 #include <linux/spinlock.h>
+#include <linux/pm_runtime.h>

 struct gpio_button_data {
        const struct gpio_keys_button *button;
@@ -526,6 +527,7 @@ static int gpio_keys_open(struct input_dev *input)
 {
        struct gpio_keys_drvdata *ddata = input_get_drvdata(input);

+       pm_runtime_get_sync(input->dev.parent);
I am not an expert of the runtime.

However would be grateful if you explain me what it actually do.

Also I did not see any runtime suspend/ resume handlers populated.
-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Re: [PATCH 2/2] input: gpio-keys: Add runtime support

From: Linus Walleij <hidden>
Date: 2012-10-12 21:09:33

On Thu, Oct 11, 2012 at 4:22 PM, Shubhrajyoti Datta
[off-list ref] wrote:
quoted
@@ -526,6 +527,7 @@ static int gpio_keys_open(struct input_dev *input)
 {
        struct gpio_keys_drvdata *ddata = input_get_drvdata(input);

+       pm_runtime_get_sync(input->dev.parent);
I am not an expert of the runtime.

However would be grateful if you explain me what it actually do.
This increase the reference count of the runtime status container
for the device. _sync makes sure it happens now.

Consult:
Documentation/power/runtime_pm.txt
Also I did not see any runtime suspend/ resume handlers populated.
It is not necessary to handle the power state at the driver level,
it can just as well be handled by the voltage/power domain,
or at the class, type or bus level.

But the individual driver has to notify the system upward if it
needs to be powered on or when it may or must be relaxed.

Yours,
Linus Walleij

Re: [PATCH 1/2] input: gpio-keys: Disable hardware on suspend

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2012-10-13 06:17:45

Hi Lee,

On Thu, Oct 11, 2012 at 03:15:26PM +0100, Lee Jones wrote:
From: Jonas Aaberg <redacted>

Disable hardware if active when suspending if the hw can not
wake the system from suspend.

Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: linux-input@vger.kernel.org
Acked-by: Lee Jones <redacted>
If you are sending the patch then it should be signed-off-by, not
acked-by, and it should be the very last entry.
quoted hunk
Signed-off-by: Jonas Aaberg <redacted>
Signed-off-by: Philippe Langlais <redacted>
Reviewed-by: Bengt Jonsson <redacted>
---
 drivers/input/keyboard/gpio_keys.c |   13 +++++++++++++
 1 file changed, 13 insertions(+)
diff --git a/drivers/input/keyboard/gpio_keys.c b/drivers/input/keyboard/gpio_keys.c
index cbb1add..7947315 100644
--- a/drivers/input/keyboard/gpio_keys.c
+++ b/drivers/input/keyboard/gpio_keys.c
@@ -46,6 +46,8 @@ struct gpio_keys_drvdata {
 	struct input_dev *input;
 	struct mutex disable_lock;
 	unsigned int n_buttons;
+	bool enabled;
+	bool enable_after_suspend;
 	int (*enable)(struct device *dev);
 	void (*disable)(struct device *dev);
 	struct gpio_button_data data[0];
@@ -524,6 +526,7 @@ static int gpio_keys_open(struct input_dev *input)
 {
 	struct gpio_keys_drvdata *ddata = input_get_drvdata(input);
 
+	ddata->enabled = true;
 	return ddata->enable ? ddata->enable(input->dev.parent) : 0;
 }
 
@@ -533,6 +536,7 @@ static void gpio_keys_close(struct input_dev *input)
 
 	if (ddata->disable)
 		ddata->disable(input->dev.parent);
+	ddata->enabled = false;
 }
 
 /*
@@ -674,6 +678,7 @@ static int __devinit gpio_keys_probe(struct platform_device *pdev)
 	ddata->n_buttons = pdata->nbuttons;
 	ddata->enable = pdata->enable;
 	ddata->disable = pdata->disable;
+	ddata->enabled = false;
 	mutex_init(&ddata->disable_lock);
 
 	platform_set_drvdata(pdev, ddata);
@@ -789,6 +794,10 @@ static int gpio_keys_suspend(struct device *dev)
 			if (bdata->button->wakeup)
 				enable_irq_wake(bdata->irq);
 		}
+	} else {
+		ddata->enable_after_suspend = ddata->enabled;
+		if (ddata->enabled)
+			gpio_keys_close(ddata->input);
I think it should take ddata->input->mutex to avoid races with
open/close and use ddata->input->users to figure out if device shoudl be
closed and re-opened later.

Thanks.
quoted hunk
 	}
 
 	return 0;
@@ -807,6 +816,10 @@ static int gpio_keys_resume(struct device *dev)
 		if (gpio_is_valid(bdata->button->gpio))
 			gpio_keys_gpio_report_event(bdata);
 	}
+
+	if (!device_may_wakeup(dev) && ddata->enable_after_suspend)
+		gpio_keys_open(ddata->input);
+
 	input_sync(ddata->input);
 
 	return 0;
-- 
1.7.9.5
-- 
Dmitry

Re: [PATCH 2/2] input: gpio-keys: Add runtime support

From: Lee Jones <hidden>
Date: 2012-10-25 07:57:19

On Fri, 12 Oct 2012, Linus Walleij wrote:
On Thu, Oct 11, 2012 at 4:22 PM, Shubhrajyoti Datta
[off-list ref] wrote:
quoted
quoted
@@ -526,6 +527,7 @@ static int gpio_keys_open(struct input_dev *input)
 {
        struct gpio_keys_drvdata *ddata = input_get_drvdata(input);

+       pm_runtime_get_sync(input->dev.parent);
I am not an expert of the runtime.

However would be grateful if you explain me what it actually do.
This increase the reference count of the runtime status container
for the device. _sync makes sure it happens now.

Consult:
Documentation/power/runtime_pm.txt
quoted
Also I did not see any runtime suspend/ resume handlers populated.
It is not necessary to handle the power state at the driver level,
it can just as well be handled by the voltage/power domain,
or at the class, type or bus level.

But the individual driver has to notify the system upward if it
needs to be powered on or when it may or must be relaxed.

Yours,
Linus Walleij
Friendly poke.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Re: [PATCH 2/2] input: gpio-keys: Add runtime support

From: Linus Walleij <hidden>
Date: 2012-10-25 08:01:38

On Thu, Oct 25, 2012 at 9:57 AM, Lee Jones [off-list ref] wrote:
On Fri, 12 Oct 2012, Linus Walleij wrote:
quoted
Yours,
Linus Walleij
Friendly poke.
This makes it look like you're poking me as I'm in the To: field but I suspect
the intent must be to poke Dmitry ... I was just providing background
for Shubhrajyoti's question.

Maybe this helps:
Reviewed-by: Linus Walleij <redacted>

Yours,
Linus Walleij

Re: [PATCH 2/2] input: gpio-keys: Add runtime support

From: Lee Jones <hidden>
Date: 2012-10-25 08:21:58

On Thu, 25 Oct 2012, Linus Walleij wrote:
On Thu, Oct 25, 2012 at 9:57 AM, Lee Jones [off-list ref] wrote:
quoted
On Fri, 12 Oct 2012, Linus Walleij wrote:
quoted
quoted
Yours,
Linus Walleij
Friendly poke.
This makes it look like you're poking me as I'm in the To: field but I suspect
the intent must be to poke Dmitry ... I was just providing background
for Shubhrajyoti's question.

Maybe this helps:
Reviewed-by: Linus Walleij <redacted>
Yes, that was also the intention of the other poke. Sorry about
that, I should have moved you into Cc: instead.

Yes, the poke was for Dmitry.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

Re: [PATCH 2/2] input: gpio-keys: Add runtime support

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Date: 2012-10-25 08:31:13

On Thu, Oct 25, 2012 at 09:21:45AM +0100, Lee Jones wrote:
On Thu, 25 Oct 2012, Linus Walleij wrote:
quoted
On Thu, Oct 25, 2012 at 9:57 AM, Lee Jones [off-list ref] wrote:
quoted
On Fri, 12 Oct 2012, Linus Walleij wrote:
quoted
quoted
Yours,
Linus Walleij
Friendly poke.
This makes it look like you're poking me as I'm in the To: field but I suspect
the intent must be to poke Dmitry ... I was just providing background
for Shubhrajyoti's question.

Maybe this helps:
Reviewed-by: Linus Walleij <redacted>
Yes, that was also the intention of the other poke. Sorry about
that, I should have moved you into Cc: instead.

Yes, the poke was for Dmitry.
Still do not have the right signoffs: person who sends me the patch needs
to put signed-off-by, not acked-by.

Thanks.

-- 
Dmitry

Re: [PATCH 2/2] input: gpio-keys: Add runtime support

From: Lee Jones <hidden>
Date: 2012-10-25 09:47:49

On Thu, 25 Oct 2012, Dmitry Torokhov wrote:
On Thu, Oct 25, 2012 at 09:21:45AM +0100, Lee Jones wrote:
quoted
On Thu, 25 Oct 2012, Linus Walleij wrote:
quoted
On Thu, Oct 25, 2012 at 9:57 AM, Lee Jones [off-list ref] wrote:
quoted
On Fri, 12 Oct 2012, Linus Walleij wrote:
quoted
quoted
Yours,
Linus Walleij
Friendly poke.
This makes it look like you're poking me as I'm in the To: field but I suspect
the intent must be to poke Dmitry ... I was just providing background
for Shubhrajyoti's question.

Maybe this helps:
Reviewed-by: Linus Walleij <redacted>
Yes, that was also the intention of the other poke. Sorry about
that, I should have moved you into Cc: instead.

Yes, the poke was for Dmitry.
Still do not have the right signoffs: person who sends me the patch needs
to put signed-off-by, not acked-by.
My apologies.

Signed-off-by: Lee Jones <redacted>

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help