linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: tca6416-keypad: Suspend/Resume wakeup support
@ 2011-03-16  5:10 Magnus Damm
  2011-03-16  5:32 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Magnus Damm @ 2011-03-16  5:10 UTC (permalink / raw)
  To: dmitry.torokhov; +Cc: srk, Magnus Damm, linux-sh, chinyeow.sim.xt, linux-input

From: Magnus Damm <damm@opensource.se>

Extend the tca6416 driver to use enable_irq_wake()
and disable_irq_wake() in the suspend/resume hooks.

This makes it possible to wake up from suspend-to-ram
using a tca6416 key on the sh7372 mackerel board.

Signed-off-by: Magnus Damm <damm@opensource.se>
---

 drivers/input/keyboard/tca6416-keypad.c |   26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

--- 0001/drivers/input/keyboard/tca6416-keypad.c
+++ work/drivers/input/keyboard/tca6416-keypad.c	2011-03-16 12:53:34.000000000 +0900
@@ -297,6 +297,7 @@ static int __devinit tca6416_keypad_prob
 	}
 
 	i2c_set_clientdata(client, chip);
+	device_init_wakeup(&client->dev, 1);
 
 	return 0;
 
@@ -326,10 +327,35 @@ static int __devexit tca6416_keypad_remo
 	return 0;
 }
 
+static int tca6416_keypad_suspend(struct device *dev)
+{
+	struct tca6416_keypad_chip *chip = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev))
+		enable_irq_wake(chip->irqnum);
+
+	return 0;
+}
+
+static int tca6416_keypad_resume(struct device *dev)
+{
+	struct tca6416_keypad_chip *chip = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev))
+		disable_irq_wake(chip->irqnum);
+
+	return 0;
+}
+
+static const struct dev_pm_ops tca6416_keypad_dev_pm_ops = {
+	.suspend = tca6416_keypad_suspend,
+	.resume = tca6416_keypad_resume,
+};
 
 static struct i2c_driver tca6416_keypad_driver = {
 	.driver = {
 		.name	= "tca6416-keypad",
+		.pm	= &tca6416_keypad_dev_pm_ops,
 	},
 	.probe		= tca6416_keypad_probe,
 	.remove		= __devexit_p(tca6416_keypad_remove),

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: tca6416-keypad: Suspend/Resume wakeup support
  2011-03-16  5:10 [PATCH] Input: tca6416-keypad: Suspend/Resume wakeup support Magnus Damm
@ 2011-03-16  5:32 ` Dmitry Torokhov
  2011-03-16  5:45   ` Magnus Damm
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2011-03-16  5:32 UTC (permalink / raw)
  To: Magnus Damm; +Cc: srk, linux-sh, chinyeow.sim.xt, linux-input

On Wed, Mar 16, 2011 at 02:10:30PM +0900, Magnus Damm wrote:
> From: Magnus Damm <damm@opensource.se>
> 
> Extend the tca6416 driver to use enable_irq_wake()
> and disable_irq_wake() in the suspend/resume hooks.
> 
> This makes it possible to wake up from suspend-to-ram
> using a tca6416 key on the sh7372 mackerel board.
> 

Hi Magnus,

Looks good, but why don't we guard PM code with CONFIG_PM_SLEEP, like
below? I also believe we should use bus-specific helpers to access
private driver data since it does not have to stay alias for the
core data pointer.

Thanks.

-- 
Dmitry


Input: tca6416-keypad - Suspend/Resume wakeup support

From: Magnus Damm <damm@opensource.se>

Extend the tca6416 driver to use enable_irq_wake()
and disable_irq_wake() in the suspend/resume hooks.

This makes it possible to wake up from suspend-to-ram
using a tca6416 key on the sh7372 mackerel board.

Signed-off-by: Magnus Damm <damm@opensource.se>
Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/keyboard/tca6416-keypad.c |   28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)


diff --git a/drivers/input/keyboard/tca6416-keypad.c b/drivers/input/keyboard/tca6416-keypad.c
index 800fbcc..3afea3f 100644
--- a/drivers/input/keyboard/tca6416-keypad.c
+++ b/drivers/input/keyboard/tca6416-keypad.c
@@ -297,6 +297,7 @@ static int __devinit tca6416_keypad_probe(struct i2c_client *client,
 	}
 
 	i2c_set_clientdata(client, chip);
+	device_init_wakeup(&client->dev, 1);
 
 	return 0;
 
@@ -326,10 +327,37 @@ static int __devexit tca6416_keypad_remove(struct i2c_client *client)
 	return 0;
 }
 
+#ifdef CONFIG_PM_SLEEP
+static int tca6416_keypad_suspend(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct tca6416_keypad_chip *chip = i2c_get_clientdata(client);
+
+	if (device_may_wakeup(dev))
+		enable_irq_wake(chip->irqnum);
+
+	return 0;
+}
+
+static int tca6416_keypad_resume(struct device *dev)
+{
+	struct i2c_client *client = to_i2c_client(dev);
+	struct tca6416_keypad_chip *chip = i2c_get_clientdata(client);
+
+	if (device_may_wakeup(dev))
+		disable_irq_wake(chip->irqnum);
+
+	return 0;
+}
+#endif
+
+static SIMPLE_DEV_PM_OPS(tca6416_keypad_dev_pm_ops,
+			 tca6416_keypad_suspend, tca6416_keypad_resume);
 
 static struct i2c_driver tca6416_keypad_driver = {
 	.driver = {
 		.name	= "tca6416-keypad",
+		.pm	= &tca6416_keypad_dev_pm_ops,
 	},
 	.probe		= tca6416_keypad_probe,
 	.remove		= __devexit_p(tca6416_keypad_remove),

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: tca6416-keypad: Suspend/Resume wakeup support
  2011-03-16  5:32 ` Dmitry Torokhov
@ 2011-03-16  5:45   ` Magnus Damm
  2011-03-16  5:51     ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Magnus Damm @ 2011-03-16  5:45 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: srk, linux-sh, chinyeow.sim.xt, linux-input

On Wed, Mar 16, 2011 at 2:32 PM, Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Wed, Mar 16, 2011 at 02:10:30PM +0900, Magnus Damm wrote:
>> From: Magnus Damm <damm@opensource.se>
>>
>> Extend the tca6416 driver to use enable_irq_wake()
>> and disable_irq_wake() in the suspend/resume hooks.
>>
>> This makes it possible to wake up from suspend-to-ram
>> using a tca6416 key on the sh7372 mackerel board.
>>
>
> Hi Magnus,
>
> Looks good, but why don't we guard PM code with CONFIG_PM_SLEEP, like
> below? I also believe we should use bus-specific helpers to access
> private driver data since it does not have to stay alias for the
> core data pointer.

Hi Dmitry,

Thank you for the updated patch, your version looks much better than
mine. I tested your version on my Mackerel board a few minutes ago and
it is still working as expected. Unless there are any objections,
please merge your version of the patch.

Cheers,

/ magnus

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: tca6416-keypad: Suspend/Resume wakeup support
  2011-03-16  5:45   ` Magnus Damm
@ 2011-03-16  5:51     ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2011-03-16  5:51 UTC (permalink / raw)
  To: Magnus Damm; +Cc: srk, linux-sh, chinyeow.sim.xt, linux-input

On Wed, Mar 16, 2011 at 02:45:11PM +0900, Magnus Damm wrote:
> On Wed, Mar 16, 2011 at 2:32 PM, Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> > On Wed, Mar 16, 2011 at 02:10:30PM +0900, Magnus Damm wrote:
> >> From: Magnus Damm <damm@opensource.se>
> >>
> >> Extend the tca6416 driver to use enable_irq_wake()
> >> and disable_irq_wake() in the suspend/resume hooks.
> >>
> >> This makes it possible to wake up from suspend-to-ram
> >> using a tca6416 key on the sh7372 mackerel board.
> >>
> >
> > Hi Magnus,
> >
> > Looks good, but why don't we guard PM code with CONFIG_PM_SLEEP, like
> > below? I also believe we should use bus-specific helpers to access
> > private driver data since it does not have to stay alias for the
> > core data pointer.
> 
> Hi Dmitry,
> 
> Thank you for the updated patch, your version looks much better than
> mine. I tested your version on my Mackerel board a few minutes ago and
> it is still working as expected. Unless there are any objections,
> please merge your version of the patch.
> 

Excellent, I'll queue it up.

Thank you for testing the updated patch.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-03-16  5:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-03-16  5:10 [PATCH] Input: tca6416-keypad: Suspend/Resume wakeup support Magnus Damm
2011-03-16  5:32 ` Dmitry Torokhov
2011-03-16  5:45   ` Magnus Damm
2011-03-16  5:51     ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).