aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/base
diff options
context:
space:
mode:
authorMing Lei <ming.lei@canonical.com>2012-08-17 10:06:59 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2012-08-17 10:37:35 -0400
commitdfe3212e0196c01402154971841463d721dea915 (patch)
tree0cb18c625b9d1b50999f8942e94be0689e1396a6 /drivers/base
parentc08f67730aba342b03f070209acc2990d3decf3c (diff)
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')
-rw-r--r--drivers/base/power/main.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 0113adc310dc..b0b072a88f5f 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)
1324 return async_error; 1324 return async_error;
1325} 1325}
1326EXPORT_SYMBOL_GPL(device_pm_wait_for_dev); 1326EXPORT_SYMBOL_GPL(device_pm_wait_for_dev);
1327
1328/**
1329 * dpm_for_each_dev - device iterator.
1330 * @data: data for the callback.
1331 * @fn: function to be called for each device.
1332 *
1333 * Iterate over devices in dpm_list, and call @fn for each device,
1334 * passing it @data.
1335 */
1336void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))
1337{
1338 struct device *dev;
1339
1340 if (!fn)
1341 return;
1342
1343 device_pm_lock();
1344 list_for_each_entry(dev, &dpm_list, power.entry)
1345 fn(dev, data);
1346 device_pm_unlock();
1347}
1348EXPORT_SYMBOL_GPL(dpm_for_each_dev);