public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jean Delvare <khali@linux-fr.org>
To: Ming Lei <tom.leiming@gmail.com>, Greg Kroah-Hartman <gregkh@suse.de>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] driver core: Silent meaningless error message
Date: Fri, 1 May 2009 14:51:51 +0200	[thread overview]
Message-ID: <20090501145151.5f97456e@hyperion.delvare> (raw)

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

             reply	other threads:[~2009-05-01 12:52 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-01 12:51 Jean Delvare [this message]
2009-05-01 15:14 ` [PATCH] driver core: Silent meaningless error message Greg KH
2009-05-09 13:25   ` Jean Delvare
2009-05-09 13:46     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20090501145151.5f97456e@hyperion.delvare \
    --to=khali@linux-fr.org \
    --cc=gregkh@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tom.leiming@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox