diff mbox

[RFC,2/3] PM / Sleep: introduce dpm_for_each_dev

Message ID 1345167949-7419-3-git-send-email-ming.lei@canonical.com (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Ming Lei Aug. 17, 2012, 1:45 a.m. UTC
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>
---
 drivers/base/power/main.c |   19 +++++++++++++++++++
 include/linux/pm.h        |    5 +++++
 2 files changed, 24 insertions(+)

Comments

Ming Lei Aug. 17, 2012, 1:54 a.m. UTC | #1
On Fri, Aug 17, 2012 at 9:45 AM, Ming Lei <ming.lei@canonical.com> wrote:
> diff --git a/include/linux/pm.h b/include/linux/pm.h
> index 44d1f23..bf86f89 100644
> --- a/include/linux/pm.h
> +++ b/include/linux/pm.h
> @@ -640,6 +640,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
>         } while (0)
>
>  extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
> +extern void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *));
>
>  extern int pm_generic_prepare(struct device *dev);
>  extern int pm_generic_suspend_late(struct device *dev);
> @@ -679,6 +680,10 @@ static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
>         return 0;
>  }
>
> +void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))

Sorry, the above line is wrong, and should be defined as 'static inline'.
Please drop this one and take the attachment patch.


Thanks,
--
Ming Lei
Greg KH Aug. 17, 2012, 3:42 a.m. UTC | #2
On Fri, Aug 17, 2012 at 09:54:56AM +0800, Ming Lei wrote:
> On Fri, Aug 17, 2012 at 9:45 AM, Ming Lei <ming.lei@canonical.com> wrote:
> > diff --git a/include/linux/pm.h b/include/linux/pm.h
> > index 44d1f23..bf86f89 100644
> > --- a/include/linux/pm.h
> > +++ b/include/linux/pm.h
> > @@ -640,6 +640,7 @@ extern void __suspend_report_result(const char *function, void *fn, int ret);
> >         } while (0)
> >
> >  extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
> > +extern void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *));
> >
> >  extern int pm_generic_prepare(struct device *dev);
> >  extern int pm_generic_suspend_late(struct device *dev);
> > @@ -679,6 +680,10 @@ static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
> >         return 0;
> >  }
> >
> > +void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))
> 
> Sorry, the above line is wrong, and should be defined as 'static inline'.
> Please drop this one and take the attachment patch.

Can you please just resend these, as this attachment was in base64 :(

--
To unsubscribe from this list: send the line "unsubscribe linux-pm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/base/power/main.c b/drivers/base/power/main.c
index 57f5814..184bcb5 100644
--- a/drivers/base/power/main.c
+++ b/drivers/base/power/main.c
@@ -1349,3 +1349,22 @@  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;
+
+	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);
diff --git a/include/linux/pm.h b/include/linux/pm.h
index 44d1f23..bf86f89 100644
--- a/include/linux/pm.h
+++ b/include/linux/pm.h
@@ -640,6 +640,7 @@  extern void __suspend_report_result(const char *function, void *fn, int ret);
 	} while (0)
 
 extern int device_pm_wait_for_dev(struct device *sub, struct device *dev);
+extern void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *));
 
 extern int pm_generic_prepare(struct device *dev);
 extern int pm_generic_suspend_late(struct device *dev);
@@ -679,6 +680,10 @@  static inline int device_pm_wait_for_dev(struct device *a, struct device *b)
 	return 0;
 }
 
+void dpm_for_each_dev(void *data, void (*fn)(struct device *, void *))
+{
+}
+
 #define pm_generic_prepare	NULL
 #define pm_generic_suspend	NULL
 #define pm_generic_resume	NULL