From: Zhang Rui <rui.zhang@intel.com>
To: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-pm <linux-pm@lists.linux-foundation.org>,
linux-acpi <linux-acpi@vger.kernel.org>
Cc: Len Brown <lenb@kernel.org>, Pavel Machek <pavel@suse.cz>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
"Van De Ven, Arjan" <arjan.van.de.ven@intel.com>,
"Zhang, Rui" <rui.zhang@intel.com>
Subject: [PATCH 4/8] introduce device async suspend
Date: Wed, 15 Jul 2009 15:38:40 +0800 [thread overview]
Message-ID: <1247643520.26272.81.camel@rzhang-dt> (raw)
introduce device async suspend.
If boot option "device_async_action" is added,
devices can be suspended asynchronously.
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/base/power/main.c | 6 +++++-
include/linux/async_dev.h | 3 ++-
drivers/base/async_dev.c | 13 ++++++++++++-
3 files changed, 19 insertions(+), 3 deletions(-)
Index: linux-2.6/drivers/base/power/main.c
===================================================================
--- linux-2.6.orig/drivers/base/power/main.c
+++ linux-2.6/drivers/base/power/main.c
@@ -24,6 +24,7 @@
#include <linux/resume-trace.h>
#include <linux/rwsem.h>
#include <linux/interrupt.h>
+#include <linux/async_dev.h>
#include "../base.h"
#include "power.h"
@@ -678,7 +679,8 @@ static int dpm_suspend(pm_message_t stat
get_device(dev);
mutex_unlock(&dpm_list_mtx);
- error = device_suspend(dev, state);
+ error = dev_async_schedule(dev, device_suspend, &state,
+ DEV_ASYNC_SUSPEND);
mutex_lock(&dpm_list_mtx);
if (error) {
@@ -693,6 +695,8 @@ static int dpm_suspend(pm_message_t stat
}
list_splice(&list, dpm_list.prev);
mutex_unlock(&dpm_list_mtx);
+
+ dev_async_synchronization();
return error;
}
Index: linux-2.6/drivers/base/async_dev.c
===================================================================
--- linux-2.6.orig/drivers/base/async_dev.c
+++ linux-2.6/drivers/base/async_dev.c
@@ -17,6 +17,8 @@
static LIST_HEAD(dev_async_list);
static int dev_async_enabled;
+typedef int (*dev_async_suspend)(struct device *, pm_message_t);
+
struct dev_async_context {
struct device *dev;
void *data;
@@ -27,10 +29,19 @@ struct dev_async_context {
static int dev_action(struct device *dev, void *func,
void *data, int type)
{
+ int error = 0;
+
if (!func)
return -EINVAL;
- return 0;
+ switch (type) {
+ case DEV_ASYNC_SUSPEND:
+ error = ((dev_async_suspend)func)(dev, *((pm_message_t *)data));
+ break;
+ default:
+ return -EINVAL;
+ }
+ return error;
}
static void dev_async_action(void *data, async_cookie_t cookie)
Index: linux-2.6/include/linux/async_dev.h
===================================================================
--- linux-2.6.orig/include/linux/async_dev.h
+++ linux-2.6/include/linux/async_dev.h
@@ -28,7 +28,8 @@ struct dev_async_struct {
async_cookie_t cookie;
};
-#define DEV_ASYNC_ACTIONS_ALL 0
+#define DEV_ASYNC_SUSPEND 1
+#define DEV_ASYNC_ACTIONS_ALL DEV_ASYNC_SUSPEND
extern int dev_async_schedule(struct device *, void *,
void *, int);
reply other threads:[~2009-07-15 7:38 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1247643520.26272.81.camel@rzhang-dt \
--to=rui.zhang@intel.com \
--cc=arjan.van.de.ven@intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=pavel@suse.cz \
--cc=rjw@sisk.pl \
/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;
as well as URLs for NNTP newsgroup(s).