]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
PM: Simplify suspend_device
authorRafael J. Wysocki <rjw@sisk.pl>
Wed, 13 Jun 2007 14:19:27 +0000 (16:19 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 11 Jul 2007 23:09:01 +0000 (16:09 -0700)
Reduce code duplication in drivers/base/suspend.c by introducing a separate
function for printing diagnostic messages.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/power/suspend.c

index 19fae88de7b3c2af0ac34f7ecfec02ede96a5051..af2cedfbc1b437831e54622c68b0152e5de848dd 100644 (file)
@@ -40,6 +40,14 @@ static inline char *suspend_verb(u32 event)
 }
 
 
+static 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, pm_message_t state)
        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 device *dev, pm_message_t state)
 {
        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);
        }