Merge tag 'pm-for-3.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael...
[firefly-linux-kernel-4.4.55.git] / drivers / base / power / main.c
index 008e6786ae7919e3e4165e6b605cb6a7836ad4c6..a3c1404c79338c3b7e82b7b71835971dc42ec358 100644 (file)
@@ -1356,3 +1356,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);