All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next 0/3] firmware loader: fix build failure
@ 2012-08-17  1:45 Ming Lei
  2012-08-17  1:45 ` [PATCH 1/3] firmware loader: fix compile failure if !PM Ming Lei
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ming Lei @ 2012-08-17  1:45 UTC (permalink / raw)
  To: Linus Torvalds, Greg Kroah-Hartman
  Cc: Rafael J. Wysocki, Borislav Petkov, linux-kernel, linux-pm

Hi Greg,

These 3 patches fix build failure reported by Fengguang aginst
driver-core -next tree.

The 2nd patch introduces dpm_for_each_dev in drivers/base/power
to fix link failure if firmware loader is complied as moudle.

Rafael, could you comment on the 2nd patch?

Thanks,
--
Ming Lei


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/3] firmware loader: fix compile failure if !PM
  2012-08-17  1:45 [PATCH -next 0/3] firmware loader: fix build failure Ming Lei
@ 2012-08-17  1:45 ` Ming Lei
  2012-08-17  1:45 ` [RFC PATCH 2/3] PM / Sleep: introduce dpm_for_each_dev Ming Lei
  2012-08-17  1:45 ` [PATCH 3/3] firmware loader: fix compile failure if FW_LOADER is m Ming Lei
  2 siblings, 0 replies; 6+ messages in thread
From: Ming Lei @ 2012-08-17  1:45 UTC (permalink / raw)
  To: Linus Torvalds, Greg Kroah-Hartman
  Cc: Rafael J. Wysocki, Borislav Petkov, linux-kernel, linux-pm,
	Ming Lei

'return 0' should be added to fw_pm_notify if !PM because
return value of the funcion is defined as 'int'.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/base/firmware_class.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 5bd2100..4c8d8ef 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -1242,7 +1242,9 @@ static int fw_pm_notify(struct notifier_block *notify_block,
 #else
 static int fw_pm_notify(struct notifier_block *notify_block,
 			unsigned long mode, void *unused)
-{}
+{
+	return 0;
+}
 #endif
 
 static void __init fw_cache_init(void)
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [RFC PATCH 2/3] PM / Sleep: introduce dpm_for_each_dev
  2012-08-17  1:45 [PATCH -next 0/3] firmware loader: fix build failure Ming Lei
  2012-08-17  1:45 ` [PATCH 1/3] firmware loader: fix compile failure if !PM Ming Lei
@ 2012-08-17  1:45 ` Ming Lei
  2012-08-17  1:54   ` Ming Lei
  2012-08-17  1:45 ` [PATCH 3/3] firmware loader: fix compile failure if FW_LOADER is m Ming Lei
  2 siblings, 1 reply; 6+ messages in thread
From: Ming Lei @ 2012-08-17  1:45 UTC (permalink / raw)
  To: Linus Torvalds, Greg Kroah-Hartman
  Cc: Rafael J. Wysocki, Borislav Petkov, linux-kernel, linux-pm,
	Ming Lei

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(+)

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
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/3] firmware loader: fix compile failure if FW_LOADER is m
  2012-08-17  1:45 [PATCH -next 0/3] firmware loader: fix build failure Ming Lei
  2012-08-17  1:45 ` [PATCH 1/3] firmware loader: fix compile failure if !PM Ming Lei
  2012-08-17  1:45 ` [RFC PATCH 2/3] PM / Sleep: introduce dpm_for_each_dev Ming Lei
@ 2012-08-17  1:45 ` Ming Lei
  2 siblings, 0 replies; 6+ messages in thread
From: Ming Lei @ 2012-08-17  1:45 UTC (permalink / raw)
  To: Linus Torvalds, Greg Kroah-Hartman
  Cc: Rafael J. Wysocki, Borislav Petkov, linux-kernel, linux-pm,
	Ming Lei

device_cache_fw_images need to iterate devices in system,
so this patch applies the introduced dpm_for_each_dev to
avoid compile failure if CONFIG_FW_LOADER is m.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
 drivers/base/firmware_class.c |    9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/base/firmware_class.c b/drivers/base/firmware_class.c
index 4c8d8ef..ed0510a 100644
--- a/drivers/base/firmware_class.c
+++ b/drivers/base/firmware_class.c
@@ -27,7 +27,6 @@
 #include <linux/suspend.h>
 
 #include "base.h"
-#include "power/power.h"
 
 MODULE_AUTHOR("Manuel Estrada Sainz");
 MODULE_DESCRIPTION("Multi purpose firmware loading support");
@@ -1093,7 +1092,7 @@ static int devm_name_match(struct device *dev, void *res,
 	return (fwn->magic == (unsigned long)match_data);
 }
 
-static void dev_cache_fw_image(struct device *dev)
+static void dev_cache_fw_image(struct device *dev, void *data)
 {
 	LIST_HEAD(todo);
 	struct fw_cache_entry *fce;
@@ -1148,7 +1147,6 @@ static void __device_uncache_fw_images(void)
 static void device_cache_fw_images(void)
 {
 	struct firmware_cache *fwc = &fw_cache;
-	struct device *dev;
 	int old_timeout;
 	DEFINE_WAIT(wait);
 
@@ -1165,10 +1163,7 @@ static void device_cache_fw_images(void)
 	old_timeout = loading_timeout;
 	loading_timeout = 10;
 
-	device_pm_lock();
-	list_for_each_entry(dev, &dpm_list, power.entry)
-		dev_cache_fw_image(dev);
-	device_pm_unlock();
+	dpm_for_each_dev(NULL, dev_cache_fw_image);
 
 	/* wait for completion of caching firmware for all devices */
 	spin_lock(&fwc->name_lock);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 2/3] PM / Sleep: introduce dpm_for_each_dev
  2012-08-17  1:45 ` [RFC PATCH 2/3] PM / Sleep: introduce dpm_for_each_dev Ming Lei
@ 2012-08-17  1:54   ` Ming Lei
  2012-08-17  3:42     ` Greg Kroah-Hartman
  0 siblings, 1 reply; 6+ messages in thread
From: Ming Lei @ 2012-08-17  1:54 UTC (permalink / raw)
  To: Linus Torvalds, Greg Kroah-Hartman
  Cc: Rafael J. Wysocki, Borislav Petkov, linux-kernel, linux-pm,
	Ming Lei

[-- Attachment #1: Type: text/plain, Size: 964 bytes --]

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

[-- Attachment #2: 0002-PM-Sleep-introduce-dpm_for_each_dev.patch --]
[-- Type: application/octet-stream, Size: 2366 bytes --]

From 068b5ff4eb4a754193bb415d845b35218948793c Mon Sep 17 00:00:00 2001
From: Ming Lei <tom.leiming@gmail.com>
Date: Fri, 17 Aug 2012 09:03:56 +0800
Subject: [RFC PATCH 2/3] 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 <tom.leiming@gmail.com>
---
 drivers/base/power/main.c |   19 +++++++++++++++++++
 include/linux/pm.h        |    5 +++++
 2 files changed, 24 insertions(+)

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..007e687 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;
 }
 
+static inline 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
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [RFC PATCH 2/3] PM / Sleep: introduce dpm_for_each_dev
  2012-08-17  1:54   ` Ming Lei
@ 2012-08-17  3:42     ` Greg Kroah-Hartman
  0 siblings, 0 replies; 6+ messages in thread
From: Greg Kroah-Hartman @ 2012-08-17  3:42 UTC (permalink / raw)
  To: Ming Lei
  Cc: Linus Torvalds, Rafael J. Wysocki, Borislav Petkov, linux-kernel,
	linux-pm

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 :(


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-08-17  3:42 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-08-17  1:45 [PATCH -next 0/3] firmware loader: fix build failure Ming Lei
2012-08-17  1:45 ` [PATCH 1/3] firmware loader: fix compile failure if !PM Ming Lei
2012-08-17  1:45 ` [RFC PATCH 2/3] PM / Sleep: introduce dpm_for_each_dev Ming Lei
2012-08-17  1:54   ` Ming Lei
2012-08-17  3:42     ` Greg Kroah-Hartman
2012-08-17  1:45 ` [PATCH 3/3] firmware loader: fix compile failure if FW_LOADER is m Ming Lei

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.