public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] driver core: Silent meaningless error message
@ 2009-05-01 12:51 Jean Delvare
  2009-05-01 15:14 ` Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Jean Delvare @ 2009-05-01 12:51 UTC (permalink / raw)
  To: Ming Lei, Greg Kroah-Hartman; +Cc: LKML

I see the following error message in my kernel logs:

w83627ehf.2576: use which platform_data?

This is caused by platform_device_add_data() setting both
pdev->platform_data and pdev->dev.platform_data, and then
platform_device_add() complaining if both pointers are set.

As platform_device_add() is now making sure that both pointers are
set, there is no point in setting both in platform_device_add_data().

Additionally, we should only issue the error message when there is a
real problem, that is: both data pointers are set and differ. And, in
this case, we should fail right away, as something is seriously wrong.

Also free the memory through pa->pdev.platform_data rather than
pa->pdev.dev.platform_data. We will have to do that someday anyway, so
we might as well start now to make the intents clearer.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Ming Lei <tom.leiming@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@suse.de>
---
 drivers/base/platform.c |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

--- linux-2.6.30-rc4.orig/drivers/base/platform.c	2009-04-22 09:51:01.000000000 +0200
+++ linux-2.6.30-rc4/drivers/base/platform.c	2009-05-01 14:09:16.000000000 +0200
@@ -143,7 +143,7 @@ static void platform_device_release(stru
 	struct platform_object *pa = container_of(dev, struct platform_object,
 						  pdev.dev);
 
-	kfree(pa->pdev.dev.platform_data);
+	kfree(pa->pdev.platform_data);
 	kfree(pa->pdev.resource);
 	kfree(pa);
 }
@@ -216,7 +216,6 @@ int platform_device_add_data(struct plat
 	d = kmalloc(size, GFP_KERNEL);
 	if (d) {
 		memcpy(d, data, size);
-		pdev->dev.platform_data = d;
 		pdev->platform_data = d;
 	}
 	return d ? 0 : -ENOMEM;
@@ -253,9 +252,12 @@ int platform_device_add(struct platform_
 	* long time, so we allow the two cases coexist to make
 	* this kind of fix more easily*/
 	if (pdev->platform_data && pdev->dev.platform_data) {
-		printk(KERN_ERR
+		if (pdev->platform_data != pdev->dev.platform_data) {
+			printk(KERN_ERR
 			       "%s: use which platform_data?\n",
 			       dev_name(&pdev->dev));
+			return -EINVAL;
+		}
 	} else if (pdev->platform_data) {
 		pdev->dev.platform_data = pdev->platform_data;
 	} else if (pdev->dev.platform_data) {


-- 
Jean Delvare

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

end of thread, other threads:[~2009-05-09 13:53 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-05-01 12:51 [PATCH] driver core: Silent meaningless error message Jean Delvare
2009-05-01 15:14 ` Greg KH
2009-05-09 13:25   ` Jean Delvare
2009-05-09 13:46     ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox