diff options
author | Rafael J. Wysocki <rjw@sisk.pl> | 2011-02-08 23:26:02 +0100 |
---|---|---|
committer | Rafael J. Wysocki <rjw@sisk.pl> | 2011-03-15 00:43:14 +0100 |
commit | cb8f51bdadb7969139c2e39c2defd4cde98c1ea8 (patch) | |
tree | a6d6e20878460d50b8f61d5fe3237818c54065eb /drivers/base/power/sysfs.c | |
parent | 4681b17154b3fd81f898802262985f662344e6ed (diff) | |
download | talos-obmc-linux-cb8f51bdadb7969139c2e39c2defd4cde98c1ea8.tar.gz talos-obmc-linux-cb8f51bdadb7969139c2e39c2defd4cde98c1ea8.zip |
PM: Do not create wakeup sysfs files for devices that cannot wake up
Currently, wakeup sysfs attributes are created for all devices,
regardless of whether or not they are wakeup-capable. This is
excessive and complicates wakeup device identification from user
space (i.e. to identify wakeup-capable devices user space has to read
/sys/devices/.../power/wakeup for all devices and see if they are not
empty).
Fix this issue by avoiding to create wakeup sysfs files for devices
that cannot wake up the system from sleep states (i.e. whose
power.can_wakeup flags are unset during registration) and modify
device_set_wakeup_capable() so that it adds (or removes) the relevant
sysfs attributes if a device's wakeup capability status is changed.
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Diffstat (limited to 'drivers/base/power/sysfs.c')
-rw-r--r-- | drivers/base/power/sysfs.c | 78 |
1 files changed, 51 insertions, 27 deletions
diff --git a/drivers/base/power/sysfs.c b/drivers/base/power/sysfs.c index 0b1e46bf3e56..fff49bee781d 100644 --- a/drivers/base/power/sysfs.c +++ b/drivers/base/power/sysfs.c @@ -431,26 +431,18 @@ static ssize_t async_store(struct device *dev, struct device_attribute *attr, static DEVICE_ATTR(async, 0644, async_show, async_store); #endif /* CONFIG_PM_ADVANCED_DEBUG */ -static struct attribute * power_attrs[] = { - &dev_attr_wakeup.attr, -#ifdef CONFIG_PM_SLEEP - &dev_attr_wakeup_count.attr, - &dev_attr_wakeup_active_count.attr, - &dev_attr_wakeup_hit_count.attr, - &dev_attr_wakeup_active.attr, - &dev_attr_wakeup_total_time_ms.attr, - &dev_attr_wakeup_max_time_ms.attr, - &dev_attr_wakeup_last_time_ms.attr, -#endif +static struct attribute *power_attrs[] = { #ifdef CONFIG_PM_ADVANCED_DEBUG +#ifdef CONFIG_PM_SLEEP &dev_attr_async.attr, +#endif #ifdef CONFIG_PM_RUNTIME &dev_attr_runtime_status.attr, &dev_attr_runtime_usage.attr, &dev_attr_runtime_active_kids.attr, &dev_attr_runtime_enabled.attr, #endif -#endif +#endif /* CONFIG_PM_ADVANCED_DEBUG */ NULL, }; static struct attribute_group pm_attr_group = { @@ -458,9 +450,26 @@ static struct attribute_group pm_attr_group = { .attrs = power_attrs, }; -#ifdef CONFIG_PM_RUNTIME +static struct attribute *wakeup_attrs[] = { +#ifdef CONFIG_PM_SLEEP + &dev_attr_wakeup.attr, + &dev_attr_wakeup_count.attr, + &dev_attr_wakeup_active_count.attr, + &dev_attr_wakeup_hit_count.attr, + &dev_attr_wakeup_active.attr, + &dev_attr_wakeup_total_time_ms.attr, + &dev_attr_wakeup_max_time_ms.attr, + &dev_attr_wakeup_last_time_ms.attr, +#endif + NULL, +}; +static struct attribute_group pm_wakeup_attr_group = { + .name = power_group_name, + .attrs = wakeup_attrs, +}; static struct attribute *runtime_attrs[] = { +#ifdef CONFIG_PM_RUNTIME #ifndef CONFIG_PM_ADVANCED_DEBUG &dev_attr_runtime_status.attr, #endif @@ -468,6 +477,7 @@ static struct attribute *runtime_attrs[] = { &dev_attr_runtime_suspended_time.attr, &dev_attr_runtime_active_time.attr, &dev_attr_autosuspend_delay_ms.attr, +#endif /* CONFIG_PM_RUNTIME */ NULL, }; static struct attribute_group pm_runtime_attr_group = { @@ -480,35 +490,49 @@ int dpm_sysfs_add(struct device *dev) int rc; rc = sysfs_create_group(&dev->kobj, &pm_attr_group); - if (rc == 0 && !dev->power.no_callbacks) { + if (rc) + return rc; + + if (pm_runtime_callbacks_present(dev)) { rc = sysfs_merge_group(&dev->kobj, &pm_runtime_attr_group); if (rc) - sysfs_remove_group(&dev->kobj, &pm_attr_group); + goto err_out; + } + + if (device_can_wakeup(dev)) { + rc = sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); + if (rc) { + if (pm_runtime_callbacks_present(dev)) + sysfs_unmerge_group(&dev->kobj, + &pm_runtime_attr_group); + goto err_out; + } } + return 0; + + err_out: + sysfs_remove_group(&dev->kobj, &pm_attr_group); return rc; } -void rpm_sysfs_remove(struct device *dev) +int wakeup_sysfs_add(struct device *dev) { - sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group); + return sysfs_merge_group(&dev->kobj, &pm_wakeup_attr_group); } -void dpm_sysfs_remove(struct device *dev) +void wakeup_sysfs_remove(struct device *dev) { - rpm_sysfs_remove(dev); - sysfs_remove_group(&dev->kobj, &pm_attr_group); + sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); } -#else /* CONFIG_PM_RUNTIME */ - -int dpm_sysfs_add(struct device * dev) +void rpm_sysfs_remove(struct device *dev) { - return sysfs_create_group(&dev->kobj, &pm_attr_group); + sysfs_unmerge_group(&dev->kobj, &pm_runtime_attr_group); } -void dpm_sysfs_remove(struct device * dev) +void dpm_sysfs_remove(struct device *dev) { + rpm_sysfs_remove(dev); + sysfs_unmerge_group(&dev->kobj, &pm_wakeup_attr_group); sysfs_remove_group(&dev->kobj, &pm_attr_group); } - -#endif |