From: "Rafael J. Wysocki" <rjw@sisk.pl>
To: linux-pm <linux-pm@lists.osdl.org>
Cc: Pavel Machek <pavel@ucw.cz>
Subject: [RFC][PATCH 1/2] PM: Reduce code duplication in the core suspend code
Date: Sun, 10 Jun 2007 15:21:14 +0200 [thread overview]
Message-ID: <200706101521.15105.rjw@sisk.pl> (raw)
In-Reply-To: <200706101519.50588.rjw@sisk.pl>
From: Rafael J. Wysocki <rjw@sisk.pl>
Reduce code duplication in drivers/base/suspend.c by introducing an inline
function for printing diagnostic messages.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
drivers/base/power/suspend.c | 49 +++++++++++++++----------------------------
1 file changed, 18 insertions(+), 31 deletions(-)
Index: linux-2.6.22-rc4/drivers/base/power/suspend.c
===================================================================
--- linux-2.6.22-rc4.orig/drivers/base/power/suspend.c 2007-06-10 13:30:45.000000000 +0200
+++ linux-2.6.22-rc4/drivers/base/power/suspend.c 2007-06-10 15:00:40.000000000 +0200
@@ -40,6 +40,14 @@ static inline char *suspend_verb(u32 eve
}
+static inline void
+suspend_device_dbg(struct device * dev, pm_message_t state, char *info)
+{
+ dev_dbg(dev, "%s%s%s\n", info, suspend_verb(state.event),
+ ((state.event == PM_EVENT_SUSPEND) && device_may_wakeup(dev)) ?
+ ", may wakeup" : "");
+}
+
/**
* suspend_device - Save state of one device.
* @dev: Device.
@@ -66,37 +74,21 @@ int suspend_device(struct device * dev,
dev->power.prev_state = dev->power.power_state;
if (dev->class && dev->class->suspend && !dev->power.power_state.event) {
- dev_dbg(dev, "class %s%s\n",
- suspend_verb(state.event),
- ((state.event == PM_EVENT_SUSPEND)
- && device_may_wakeup(dev))
- ? ", may wakeup"
- : ""
- );
+ suspend_device_dbg(dev, state, "class ");
error = dev->class->suspend(dev, state);
suspend_report_result(dev->class->suspend, error);
}
- if (!error && dev->type && dev->type->suspend && !dev->power.power_state.event) {
- dev_dbg(dev, "%s%s\n",
- suspend_verb(state.event),
- ((state.event == PM_EVENT_SUSPEND)
- && device_may_wakeup(dev))
- ? ", may wakeup"
- : ""
- );
+ if (!error && dev->type && dev->type->suspend
+ && !dev->power.power_state.event) {
+ suspend_device_dbg(dev, state, "type ");
error = dev->type->suspend(dev, state);
suspend_report_result(dev->type->suspend, error);
}
- if (!error && dev->bus && dev->bus->suspend && !dev->power.power_state.event) {
- dev_dbg(dev, "%s%s\n",
- suspend_verb(state.event),
- ((state.event == PM_EVENT_SUSPEND)
- && device_may_wakeup(dev))
- ? ", may wakeup"
- : ""
- );
+ if (!error && dev->bus && dev->bus->suspend
+ && !dev->power.power_state.event) {
+ suspend_device_dbg(dev, state, "");
error = dev->bus->suspend(dev, state);
suspend_report_result(dev->bus->suspend, error);
}
@@ -114,14 +106,9 @@ static int suspend_device_late(struct de
{
int error = 0;
- if (dev->bus && dev->bus->suspend_late && !dev->power.power_state.event) {
- dev_dbg(dev, "LATE %s%s\n",
- suspend_verb(state.event),
- ((state.event == PM_EVENT_SUSPEND)
- && device_may_wakeup(dev))
- ? ", may wakeup"
- : ""
- );
+ if (dev->bus && dev->bus->suspend_late
+ && !dev->power.power_state.event) {
+ suspend_device_dbg(dev, state, "LATE ");
error = dev->bus->suspend_late(dev, state);
suspend_report_result(dev->bus->suspend_late, error);
}
next prev parent reply other threads:[~2007-06-10 13:21 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-06-10 13:19 [RFC][PATCH 0/2] PM: More suspend core modifications Rafael J. Wysocki
2007-06-10 13:21 ` Rafael J. Wysocki [this message]
2007-06-10 14:55 ` [RFC][PATCH 1/2] PM: Reduce code duplication in the core suspend code Alan Stern
2007-06-10 16:42 ` Rafael J. Wysocki
2007-06-10 20:37 ` Alan Stern
2007-06-10 22:43 ` Rafael J. Wysocki
2007-06-10 19:15 ` Pavel Machek
2007-06-10 13:22 ` [RFC][PATCH 2/2] PM: Remove suspend and resume support from struct device_type Rafael J. Wysocki
2007-06-10 19:22 ` Pavel Machek
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=200706101521.15105.rjw@sisk.pl \
--to=rjw@sisk.pl \
--cc=linux-pm@lists.osdl.org \
--cc=pavel@ucw.cz \
/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