diff options
author | Ming Lei <ming.lei@canonical.com> | 2012-08-17 22:06:59 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-08-17 07:37:35 -0700 |
commit | dfe3212e0196c01402154971841463d721dea915 (patch) | |
tree | 0cb18c625b9d1b50999f8942e94be0689e1396a6 /drivers/base/power | |
parent | c08f67730aba342b03f070209acc2990d3decf3c (diff) | |
download | op-kernel-dev-dfe3212e0196c01402154971841463d721dea915.zip op-kernel-dev-dfe3212e0196c01402154971841463d721dea915.tar.gz |
PM / Sleep: introduce dpm_for_each_dev
dpm_list and its pm lock provide a good way to iterate all
devices in system. Except this way, there is no other easy
way to iterate devices in system.
firmware loader need to cache firmware images for devices
before system sleep, so introduce the function to meet its
demand.
Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/base/power')
-rw-r--r-- | drivers/base/power/main.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c index 0113adc..b0b072a 100644 --- a/drivers/base/power/main.c +++ b/drivers/base/power/main.c @@ -1324,3 +1324,25 @@ int device_pm_wait_for_dev(struct device *subordinate, struct device *dev) return async_error; } EXPORT_SYMBOL_GPL(device_pm_wait_for_dev); + +/** + * dpm_for_each_dev - device iterator. + * @data: data for the callback. + * @fn: function to be called for each device. + * + * Iterate over devices in dpm_list, and call @fn for each device, + * passing it @data. + */ +void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *)) +{ + struct device *dev; + + if (!fn) + return; + + device_pm_lock(); + list_for_each_entry(dev, &dpm_list, power.entry) + fn(dev, data); + device_pm_unlock(); +} +EXPORT_SYMBOL_GPL(dpm_for_each_dev); |