public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Magnus Damm <magnus.damm@gmail.com>
To: linux-pm@lists.linux-foundation.org
Cc: gregkh@suse.de
Subject: [PATCH 05/05] PM: Runtime PM v13 - platform device bus support
Date: Fri, 07 Aug 2009 16:34:01 +0900	[thread overview]
Message-ID: <20090807073401.22479.20075.sendpatchset@rx1.opensource.se> (raw)
In-Reply-To: <20090807073315.22479.89012.sendpatchset@rx1.opensource.se>

From: Magnus Damm <damm@igel.co.jp>

This patch adds default Runtime PM callbacks to the dev_pm_ops
belonging to the platform bus. The callbacks are weak symbols
that architecture specific code may override. Also, call
pm_runtime_enable() for the platform bus struct device.

Allows Runtime PM even though CONFIG_PM_SLEEP=n.

Signed-off-by: Magnus Damm <damm@igel.co.jp>
---

 Please let me know if this platform device core change is acceptable.

 Changes:
 - Based on "Driver Core: Runtime PM callbacks for the Platform Bus V2"
 - Reworked to handle CONFIG_PM_SLEEP=n case

 drivers/base/platform.c |   48 ++++++++++++++++++++++++++++++++++++++---------
 1 file changed, 39 insertions(+), 9 deletions(-)

--- 0001/drivers/base/platform.c
+++ work/drivers/base/platform.c	2009-08-07 15:25:14.000000000 +0900
@@ -17,6 +17,7 @@
 #include <linux/bootmem.h>
 #include <linux/err.h>
 #include <linux/slab.h>
+#include <linux/pm_runtime.h>
 
 #include "base.h"
 
@@ -683,6 +684,13 @@ static void platform_pm_complete(struct 
 		drv->pm->complete(dev);
 }
 
+#else /* !CONFIG_PM_SLEEP */
+
+#define platform_pm_prepare		NULL
+#define platform_pm_complete		NULL
+
+#endif /* !CONFIG_PM_SLEEP */
+
 #ifdef CONFIG_SUSPEND
 
 static int platform_pm_suspend(struct device *dev)
@@ -925,6 +933,30 @@ static int platform_pm_restore_noirq(str
 
 #endif /* !CONFIG_HIBERNATION */
 
+#ifdef CONFIG_PM_RUNTIME
+
+int __weak platform_pm_runtime_suspend(struct device *dev)
+{
+	return -ENOSYS;
+};
+
+int __weak platform_pm_runtime_resume(struct device *dev)
+{
+	return -ENOSYS;
+};
+
+void __weak platform_pm_runtime_idle(struct device *dev)
+{
+};
+
+#else /* !CONFIG_PM_RUNTIME */
+
+#define platform_pm_runtime_suspend NULL
+#define platform_pm_runtime_resume NULL
+#define platform_pm_runtime_idle NULL
+
+#endif /* !CONFIG_PM_RUNTIME */
+
 static struct dev_pm_ops platform_dev_pm_ops = {
 	.prepare = platform_pm_prepare,
 	.complete = platform_pm_complete,
@@ -940,22 +972,17 @@ static struct dev_pm_ops platform_dev_pm
 	.thaw_noirq = platform_pm_thaw_noirq,
 	.poweroff_noirq = platform_pm_poweroff_noirq,
 	.restore_noirq = platform_pm_restore_noirq,
+	.runtime_suspend = platform_pm_runtime_suspend,
+	.runtime_resume = platform_pm_runtime_resume,
+	.runtime_idle = platform_pm_runtime_idle,
 };
 
-#define PLATFORM_PM_OPS_PTR	(&platform_dev_pm_ops)
-
-#else /* !CONFIG_PM_SLEEP */
-
-#define PLATFORM_PM_OPS_PTR	NULL
-
-#endif /* !CONFIG_PM_SLEEP */
-
 struct bus_type platform_bus_type = {
 	.name		= "platform",
 	.dev_attrs	= platform_dev_attrs,
 	.match		= platform_match,
 	.uevent		= platform_uevent,
-	.pm		= PLATFORM_PM_OPS_PTR,
+	.pm		= &platform_dev_pm_ops,
 };
 EXPORT_SYMBOL_GPL(platform_bus_type);
 
@@ -968,6 +995,9 @@ int __init platform_bus_init(void)
 	error = device_register(&platform_bus);
 	if (error)
 		return error;
+
+	pm_runtime_enable(&platform_bus);
+
 	error =  bus_register(&platform_bus_type);
 	if (error)
 		device_unregister(&platform_bus);

  parent reply	other threads:[~2009-08-07  7:34 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-08-07  7:33 [PATCH 00/05] PM: Runtime PM v13 for Platform Devices 20090807 Magnus Damm
2009-08-07  7:33 ` [PATCH 01/05] PM: Runtime PM v13 - add dev_pm_ops helpers Magnus Damm
2009-08-07  7:33 ` [PATCH 02/05] PM: Runtime PM v13 - let bus-less devices succeed Magnus Damm
2009-08-07  7:33 ` [PATCH 03/05] PM: Runtime PM v13 - add debug printouts Magnus Damm
2009-08-08 13:28   ` Rafael J. Wysocki
2009-08-07  7:33 ` [PATCH 04/05] PM: Runtime PM v13 - CONFIG_PM_SLEEP=n support Magnus Damm
2009-08-07  7:34 ` Magnus Damm [this message]
2009-08-07 14:32 ` [PATCH 00/05] PM: Runtime PM v13 for Platform Devices 20090807 Alan Stern
2009-08-07 15:42   ` Magnus Damm
2009-08-07 16:17     ` Alan Stern
2009-08-08 13:47       ` Rafael J. Wysocki
2009-08-10 10:57       ` Magnus Damm

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=20090807073401.22479.20075.sendpatchset@rx1.opensource.se \
    --to=magnus.damm@gmail.com \
    --cc=gregkh@suse.de \
    --cc=linux-pm@lists.linux-foundation.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox