aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2010-05-20 12:03:55 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-05-20 12:03:55 -0400
commit46ee9645094ad1eb5b4888882ecaa1fb87dcd2a3 (patch)
treed0a48e993568b6a2415cfc21fc06eaa2fd886429 /drivers/base
parentfa5312d9e87e7222c6c384c4e930dc149bc1178d (diff)
parent25f3a5a2854dce8b8413fd24cc9d5b9e3632be54 (diff)
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/suspend-2.6: PM: PM QOS update fix Freezer / cgroup freezer: Update stale locking comments PM / platform_bus: Allow runtime PM by default i2c: Fix bus-level power management callbacks PM QOS update PM / Hibernate: Fix block_io.c printk warning PM / Hibernate: Group swap ops PM / Hibernate: Move the first_sector out of swsusp_write PM / Hibernate: Separate block_io PM / Hibernate: Snapshot cleanup FS / libfs: Implement simple_write_to_buffer PM / Hibernate: document open(/dev/snapshot) side effects PM / Runtime: Add sysfs debug files PM: Improve device power management document PM: Update device power management document PM: Allow runtime_suspend methods to call pm_schedule_suspend() PM: pm_wakeup - switch to using bool
Diffstat (limited to 'drivers/base')
-rw-r--r--drivers/base/platform.c6
-rw-r--r--drivers/base/power/runtime.c10
-rw-r--r--drivers/base/power/sysfs.c65
3 files changed, 70 insertions, 11 deletions
diff --git a/drivers/base/platform.c b/drivers/base/platform.c
index 765bcf0df3bb..ada6397c23a5 100644
--- a/drivers/base/platform.c
+++ b/drivers/base/platform.c
@@ -967,17 +967,17 @@ static int platform_pm_restore_noirq(struct device *dev)
967 967
968int __weak platform_pm_runtime_suspend(struct device *dev) 968int __weak platform_pm_runtime_suspend(struct device *dev)
969{ 969{
970 return -ENOSYS; 970 return pm_generic_runtime_suspend(dev);
971}; 971};
972 972
973int __weak platform_pm_runtime_resume(struct device *dev) 973int __weak platform_pm_runtime_resume(struct device *dev)
974{ 974{
975 return -ENOSYS; 975 return pm_generic_runtime_resume(dev);
976}; 976};
977 977
978int __weak platform_pm_runtime_idle(struct device *dev) 978int __weak platform_pm_runtime_idle(struct device *dev)
979{ 979{
980 return -ENOSYS; 980 return pm_generic_runtime_idle(dev);
981}; 981};
982 982
983#else /* !CONFIG_PM_RUNTIME */ 983#else /* !CONFIG_PM_RUNTIME */
diff --git a/drivers/base/power/runtime.c b/drivers/base/power/runtime.c
index 626dd147b75f..b0ec0e9f27e9 100644
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -229,14 +229,16 @@ int __pm_runtime_suspend(struct device *dev, bool from_wq)
229 229
230 if (retval) { 230 if (retval) {
231 dev->power.runtime_status = RPM_ACTIVE; 231 dev->power.runtime_status = RPM_ACTIVE;
232 pm_runtime_cancel_pending(dev);
233
234 if (retval == -EAGAIN || retval == -EBUSY) { 232 if (retval == -EAGAIN || retval == -EBUSY) {
235 notify = true; 233 if (dev->power.timer_expires == 0)
234 notify = true;
236 dev->power.runtime_error = 0; 235 dev->power.runtime_error = 0;
236 } else {
237 pm_runtime_cancel_pending(dev);
237 } 238 }
238 } else { 239 } else {
239 dev->power.runtime_status = RPM_SUSPENDED; 240 dev->power.runtime_status = RPM_SUSPENDED;
241 pm_runtime_deactivate_timer(dev);
240 242
241 if (dev->parent) { 243 if (dev->parent) {
242 parent = dev->parent; 244 parent = dev->parent;
@@ -659,8 +661,6 @@ int pm_schedule_suspend(struct device *dev, unsigned int delay)
659 661
660 if (dev->power.runtime_status == RPM_SUSPENDED) 662 if (dev->power.runtime_status == RPM_SUSPENDED)
661 retval = 1; 663 retval = 1;
662 else if (dev->power.runtime_status == RPM_SUSPENDING)
663 retval = -EINPROGRESS;
664 else if (atomic_read(&dev->power.usage_count) > 0 664 else if (atomic_read(&dev->power.usage_count) > 0
665 || dev->power.disable_depth > 0) 665 || dev->power.disable_depth > 0)
666 retval = -EAGAIN; 666 retval = -EAGAIN;
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c
index 86fd9373447e..a4c33bc51257 100644
--- a/drivers/base/power/sysfs.c
+++ b/drivers/base/power/sysfs.c
@@ -5,6 +5,7 @@
5#include <linux/device.h> 5#include <linux/device.h>
6#include <linux/string.h> 6#include <linux/string.h>
7#include <linux/pm_runtime.h> 7#include <linux/pm_runtime.h>
8#include <asm/atomic.h>
8#include "power.h" 9#include "power.h"
9 10
10/* 11/*
@@ -143,7 +144,59 @@ wake_store(struct device * dev, struct device_attribute *attr,
143 144
144static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store); 145static DEVICE_ATTR(wakeup, 0644, wake_show, wake_store);
145 146
146#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG 147#ifdef CONFIG_PM_ADVANCED_DEBUG
148#ifdef CONFIG_PM_RUNTIME
149
150static ssize_t rtpm_usagecount_show(struct device *dev,
151 struct device_attribute *attr, char *buf)
152{
153 return sprintf(buf, "%d\n", atomic_read(&dev->power.usage_count));
154}
155
156static ssize_t rtpm_children_show(struct device *dev,
157 struct device_attribute *attr, char *buf)
158{
159 return sprintf(buf, "%d\n", dev->power.ignore_children ?
160 0 : atomic_read(&dev->power.child_count));
161}
162
163static ssize_t rtpm_enabled_show(struct device *dev,
164 struct device_attribute *attr, char *buf)
165{
166 if ((dev->power.disable_depth) && (dev->power.runtime_auto == false))
167 return sprintf(buf, "disabled & forbidden\n");
168 else if (dev->power.disable_depth)
169 return sprintf(buf, "disabled\n");
170 else if (dev->power.runtime_auto == false)
171 return sprintf(buf, "forbidden\n");
172 return sprintf(buf, "enabled\n");
173}
174
175static ssize_t rtpm_status_show(struct device *dev,
176 struct device_attribute *attr, char *buf)
177{
178 if (dev->power.runtime_error)
179 return sprintf(buf, "error\n");
180 switch (dev->power.runtime_status) {
181 case RPM_SUSPENDED:
182 return sprintf(buf, "suspended\n");
183 case RPM_SUSPENDING:
184 return sprintf(buf, "suspending\n");
185 case RPM_RESUMING:
186 return sprintf(buf, "resuming\n");
187 case RPM_ACTIVE:
188 return sprintf(buf, "active\n");
189 }
190 return -EIO;
191}
192
193static DEVICE_ATTR(runtime_usage, 0444, rtpm_usagecount_show, NULL);
194static DEVICE_ATTR(runtime_active_kids, 0444, rtpm_children_show, NULL);
195static DEVICE_ATTR(runtime_status, 0444, rtpm_status_show, NULL);
196static DEVICE_ATTR(runtime_enabled, 0444, rtpm_enabled_show, NULL);
197
198#endif
199
147static ssize_t async_show(struct device *dev, struct device_attribute *attr, 200static ssize_t async_show(struct device *dev, struct device_attribute *attr,
148 char *buf) 201 char *buf)
149{ 202{
@@ -170,15 +223,21 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr,
170} 223}
171 224
172static DEVICE_ATTR(async, 0644, async_show, async_store); 225static DEVICE_ATTR(async, 0644, async_show, async_store);
173#endif /* CONFIG_PM_SLEEP_ADVANCED_DEBUG */ 226#endif /* CONFIG_PM_ADVANCED_DEBUG */
174 227
175static struct attribute * power_attrs[] = { 228static struct attribute * power_attrs[] = {
176#ifdef CONFIG_PM_RUNTIME 229#ifdef CONFIG_PM_RUNTIME
177 &dev_attr_control.attr, 230 &dev_attr_control.attr,
178#endif 231#endif
179 &dev_attr_wakeup.attr, 232 &dev_attr_wakeup.attr,
180#ifdef CONFIG_PM_SLEEP_ADVANCED_DEBUG 233#ifdef CONFIG_PM_ADVANCED_DEBUG
181 &dev_attr_async.attr, 234 &dev_attr_async.attr,
235#ifdef CONFIG_PM_RUNTIME
236 &dev_attr_runtime_usage.attr,
237 &dev_attr_runtime_active_kids.attr,
238 &dev_attr_runtime_status.attr,
239 &dev_attr_runtime_enabled.attr,
240#endif
182#endif 241#endif
183 NULL, 242 NULL,
184}; 243};