diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2007-06-13 10:19:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2007-07-11 19:09:01 -0400 |
commit | 9e584a4fe58881e2dc8f09bdf8444b199ab5ecaf (patch) | |
tree | fc35a8a1c25182499b20c2416ac0225ba7829138 /drivers/base/power | |
parent | cc4900690bf77257996e90f0059eb074b8db52e6 (diff) |
PM: Simplify suspend_device
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>
Diffstat (limited to 'drivers/base/power')
-rw-r--r-- | drivers/base/power/suspend.c | 49 |
1 files changed, 18 insertions, 31 deletions
diff --git a/drivers/base/power/suspend.c b/drivers/base/power/suspend.c index 19fae88de7b3..af2cedfbc1b4 100644 --- a/drivers/base/power/suspend.c +++ b/drivers/base/power/suspend.c | |||
@@ -40,6 +40,14 @@ static inline char *suspend_verb(u32 event) | |||
40 | } | 40 | } |
41 | 41 | ||
42 | 42 | ||
43 | static void | ||
44 | suspend_device_dbg(struct device *dev, pm_message_t state, char *info) | ||
45 | { | ||
46 | dev_dbg(dev, "%s%s%s\n", info, suspend_verb(state.event), | ||
47 | ((state.event == PM_EVENT_SUSPEND) && device_may_wakeup(dev)) ? | ||
48 | ", may wakeup" : ""); | ||
49 | } | ||
50 | |||
43 | /** | 51 | /** |
44 | * suspend_device - Save state of one device. | 52 | * suspend_device - Save state of one device. |
45 | * @dev: Device. | 53 | * @dev: Device. |
@@ -66,37 +74,21 @@ int suspend_device(struct device * dev, pm_message_t state) | |||
66 | dev->power.prev_state = dev->power.power_state; | 74 | dev->power.prev_state = dev->power.power_state; |
67 | 75 | ||
68 | if (dev->class && dev->class->suspend && !dev->power.power_state.event) { | 76 | if (dev->class && dev->class->suspend && !dev->power.power_state.event) { |
69 | dev_dbg(dev, "class %s%s\n", | 77 | suspend_device_dbg(dev, state, "class "); |
70 | suspend_verb(state.event), | ||
71 | ((state.event == PM_EVENT_SUSPEND) | ||
72 | && device_may_wakeup(dev)) | ||
73 | ? ", may wakeup" | ||
74 | : "" | ||
75 | ); | ||
76 | error = dev->class->suspend(dev, state); | 78 | error = dev->class->suspend(dev, state); |
77 | suspend_report_result(dev->class->suspend, error); | 79 | suspend_report_result(dev->class->suspend, error); |
78 | } | 80 | } |
79 | 81 | ||
80 | if (!error && dev->type && dev->type->suspend && !dev->power.power_state.event) { | 82 | if (!error && dev->type && dev->type->suspend |
81 | dev_dbg(dev, "%s%s\n", | 83 | && !dev->power.power_state.event) { |
82 | suspend_verb(state.event), | 84 | suspend_device_dbg(dev, state, "type "); |
83 | ((state.event == PM_EVENT_SUSPEND) | ||
84 | && device_may_wakeup(dev)) | ||
85 | ? ", may wakeup" | ||
86 | : "" | ||
87 | ); | ||
88 | error = dev->type->suspend(dev, state); | 85 | error = dev->type->suspend(dev, state); |
89 | suspend_report_result(dev->type->suspend, error); | 86 | suspend_report_result(dev->type->suspend, error); |
90 | } | 87 | } |
91 | 88 | ||
92 | if (!error && dev->bus && dev->bus->suspend && !dev->power.power_state.event) { | 89 | if (!error && dev->bus && dev->bus->suspend |
93 | dev_dbg(dev, "%s%s\n", | 90 | && !dev->power.power_state.event) { |
94 | suspend_verb(state.event), | 91 | suspend_device_dbg(dev, state, ""); |
95 | ((state.event == PM_EVENT_SUSPEND) | ||
96 | && device_may_wakeup(dev)) | ||
97 | ? ", may wakeup" | ||
98 | : "" | ||
99 | ); | ||
100 | error = dev->bus->suspend(dev, state); | 92 | error = dev->bus->suspend(dev, state); |
101 | suspend_report_result(dev->bus->suspend, error); | 93 | suspend_report_result(dev->bus->suspend, error); |
102 | } | 94 | } |
@@ -114,14 +106,9 @@ static int suspend_device_late(struct device *dev, pm_message_t state) | |||
114 | { | 106 | { |
115 | int error = 0; | 107 | int error = 0; |
116 | 108 | ||
117 | if (dev->bus && dev->bus->suspend_late && !dev->power.power_state.event) { | 109 | if (dev->bus && dev->bus->suspend_late |
118 | dev_dbg(dev, "LATE %s%s\n", | 110 | && !dev->power.power_state.event) { |
119 | suspend_verb(state.event), | 111 | suspend_device_dbg(dev, state, "LATE "); |
120 | ((state.event == PM_EVENT_SUSPEND) | ||
121 | && device_may_wakeup(dev)) | ||
122 | ? ", may wakeup" | ||
123 | : "" | ||
124 | ); | ||
125 | error = dev->bus->suspend_late(dev, state); | 112 | error = dev->bus->suspend_late(dev, state); |
126 | suspend_report_result(dev->bus->suspend_late, error); | 113 | suspend_report_result(dev->bus->suspend_late, error); |
127 | } | 114 | } |