linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC/RFT] serio - switch to using dev_pm_ops
@ 2009-07-21  8:06 Dmitry Torokhov
  2009-07-21 21:48 ` Alan Jenkins
  0 siblings, 1 reply; 3+ messages in thread
From: Dmitry Torokhov @ 2009-07-21  8:06 UTC (permalink / raw)
  To: linux-input; +Cc: linux-kernel

And here is the serio conversion to the new PM infrastructure.

-- 
Dmitry

Input: serio - switch to using dev_pm_ops

From: Dmitry Torokhov <dmitry.torokhov@gmail.com>

Signed-off-by: Dmitry Torokhov <dtor@mail.ru>
---

 drivers/input/serio/serio.c |   30 ++++++++++++++++--------------
 1 files changed, 16 insertions(+), 14 deletions(-)


diff --git a/drivers/input/serio/serio.c b/drivers/input/serio/serio.c
index d66f494..4251a63 100644
--- a/drivers/input/serio/serio.c
+++ b/drivers/input/serio/serio.c
@@ -931,15 +931,11 @@ static int serio_uevent(struct device *dev, struct kobj_uevent_env *env)
 #endif /* CONFIG_HOTPLUG */
 
 #ifdef CONFIG_PM
-static int serio_suspend(struct device *dev, pm_message_t state)
+static int serio_suspend(struct device *dev)
 {
 	struct serio *serio = to_serio_port(dev);
 
-	if (!serio->suspended && state.event == PM_EVENT_SUSPEND)
-		serio_cleanup(serio);
-
-	serio->suspended = state.event == PM_EVENT_SUSPEND ||
-			   state.event == PM_EVENT_FREEZE;
+	serio_cleanup(serio);
 
 	return 0;
 }
@@ -952,15 +948,24 @@ static int serio_resume(struct device *dev)
 	 * Driver reconnect can take a while, so better let kseriod
 	 * deal with it.
 	 */
-	if (serio->suspended) {
-		serio->suspended = false;
-		serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
-	}
+	serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
 
 	return 0;
 }
+#else
+#define serio_suspend	NULL
+#define serio_resume	NULL
 #endif /* CONFIG_PM */
 
+static const struct dev_pm_ops serio_pm_ops = {
+	.suspend	= serio_suspend,
+	.resume		= serio_resume,
+	.poweroff	= serio_suspend,
+	.thaw		= serio_resume,
+};
+
+
+
 /* called from serio_driver->connect/disconnect methods under serio_mutex */
 int serio_open(struct serio *serio, struct serio_driver *drv)
 {
@@ -1014,10 +1019,7 @@ static struct bus_type serio_bus = {
 	.probe		= serio_driver_probe,
 	.remove		= serio_driver_remove,
 	.shutdown	= serio_shutdown,
-#ifdef CONFIG_PM
-	.suspend	= serio_suspend,
-	.resume		= serio_resume,
-#endif
+	.pm		= &serio_pm_ops,
 };
 
 static int __init serio_init(void)

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

* Re: [RFC/RFT] serio - switch to using dev_pm_ops
  2009-07-21  8:06 [RFC/RFT] serio - switch to using dev_pm_ops Dmitry Torokhov
@ 2009-07-21 21:48 ` Alan Jenkins
  2009-07-22 16:38   ` Dmitry Torokhov
  0 siblings, 1 reply; 3+ messages in thread
From: Alan Jenkins @ 2009-07-21 21:48 UTC (permalink / raw)
  To: Dmitry Torokhov; +Cc: linux-input, linux-kernel

>  drivers/input/serio/serio.c |   30 ++++++++++++++++--------------
>  1 files changed, 16 insertions(+), 14 deletions(-)

> -	if (!serio->suspended && state.event == PM_EVENT_SUSPEND)
> -		serio_cleanup(serio);
> -
> -	serio->suspended = state.event == PM_EVENT_SUSPEND ||
> -			   state.event == PM_EVENT_FREEZE;

> -	if (serio->suspended) {
> -		serio->suspended = false;
> -		serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
> -	}

It looks like you should be able to remove the suspended field of
struct serio.  Or is it used somewhere else?

Regards
Alan

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

* Re: [RFC/RFT] serio - switch to using dev_pm_ops
  2009-07-21 21:48 ` Alan Jenkins
@ 2009-07-22 16:38   ` Dmitry Torokhov
  0 siblings, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2009-07-22 16:38 UTC (permalink / raw)
  To: Alan Jenkins; +Cc: linux-input, linux-kernel

On Tue, Jul 21, 2009 at 10:48:05PM +0100, Alan Jenkins wrote:
> >  drivers/input/serio/serio.c |   30 ++++++++++++++++--------------
> >  1 files changed, 16 insertions(+), 14 deletions(-)
> 
> > -	if (!serio->suspended && state.event == PM_EVENT_SUSPEND)
> > -		serio_cleanup(serio);
> > -
> > -	serio->suspended = state.event == PM_EVENT_SUSPEND ||
> > -			   state.event == PM_EVENT_FREEZE;
> 
> > -	if (serio->suspended) {
> > -		serio->suspended = false;
> > -		serio_queue_event(serio, NULL, SERIO_RECONNECT_PORT);
> > -	}
> 
> It looks like you should be able to remove the suspended field of
> struct serio.  Or is it used somewhere else?
> 

No, it is not needed now, thanks for noticing.

-- 
Dmitry

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

end of thread, other threads:[~2009-07-22 16:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-21  8:06 [RFC/RFT] serio - switch to using dev_pm_ops Dmitry Torokhov
2009-07-21 21:48 ` Alan Jenkins
2009-07-22 16:38   ` 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).