mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Rene Herman <rene.herman@keyaccess.nl>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Greg KH <greg@kroah.com>,
	Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: Re: driver,platform,firmware,system, data data data ....
Date: Tue, 10 Oct 2006 07:48:07 +0200	[thread overview]
Message-ID: <452B3417.7050106@keyaccess.nl> (raw)
In-Reply-To: <1160451368.32237.78.camel@localhost.localdomain>

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

Benjamin Herrenschmidt wrote:

[ device->platform_data ]

> So except for the size of the patch and boredom of going through all
> of them fixing them, do you see any reason why this later one
> shouldn't be moved out to platform_driver ? (I haven't actually
> checked at all the occurences in the tree though).

You'll find it being used in drivers/base/isa.c for one. I only used it 
there because it was available and made for slightly nicer code though. 
If platform_data is going away (and assuming you wouldn't want similar 
abuse of your new system_data) it wouldn't be a problem to move the 
driver pointer to the private struct isa_dev as in the attached.

Rene.

[-- Attachment #2: isa_bus_platform_data.diff --]
[-- Type: text/plain, Size: 3332 bytes --]

Index: local/drivers/base/isa.c
===================================================================
--- local.orig/drivers/base/isa.c	2006-09-16 20:43:03.000000000 +0200
+++ local/drivers/base/isa.c	2006-10-10 07:03:54.000000000 +0200
@@ -16,6 +16,7 @@
 struct isa_dev {
 	struct device dev;
 	struct device *next;
+	struct isa_driver *isa_driver;
 	unsigned int id;
 };
 
@@ -23,61 +24,66 @@
 
 static int isa_bus_match(struct device *dev, struct device_driver *driver)
 {
-	struct isa_driver *isa_driver = to_isa_driver(driver);
+	struct isa_dev *isa_dev = to_isa_dev(dev);
+	struct isa_driver *isa_driver = isa_dev->isa_driver;
 
-	if (dev->platform_data == isa_driver) {
-		if (!isa_driver->match ||
-			isa_driver->match(dev, to_isa_dev(dev)->id))
+	if (isa_driver == to_isa_driver(driver))  {
+		if (!isa_driver->match || isa_driver->match(dev, isa_dev->id))
 			return 1;
-		dev->platform_data = NULL;
+		isa_dev->isa_driver = NULL;
 	}
 	return 0;
 }
 
 static int isa_bus_probe(struct device *dev)
 {
-	struct isa_driver *isa_driver = dev->platform_data;
+	struct isa_dev *isa_dev = to_isa_dev(dev);
+	struct isa_driver *isa_driver = isa_dev->isa_driver;
 
 	if (isa_driver->probe)
-		return isa_driver->probe(dev, to_isa_dev(dev)->id);
+		return isa_driver->probe(dev, isa_dev->id);
 
 	return 0;
 }
 
 static int isa_bus_remove(struct device *dev)
 {
-	struct isa_driver *isa_driver = dev->platform_data;
+	struct isa_dev *isa_dev = to_isa_dev(dev);
+	struct isa_driver *isa_driver = isa_dev->isa_driver;
 
 	if (isa_driver->remove)
-		return isa_driver->remove(dev, to_isa_dev(dev)->id);
+		return isa_driver->remove(dev, isa_dev->id);
 
 	return 0;
 }
 
 static void isa_bus_shutdown(struct device *dev)
 {
-	struct isa_driver *isa_driver = dev->platform_data;
+	struct isa_dev *isa_dev = to_isa_dev(dev);
+	struct isa_driver *isa_driver = isa_dev->isa_driver;
 
 	if (isa_driver->shutdown)
-		isa_driver->shutdown(dev, to_isa_dev(dev)->id);
+		isa_driver->shutdown(dev, isa_dev->id);
 }
 
 static int isa_bus_suspend(struct device *dev, pm_message_t state)
 {
-	struct isa_driver *isa_driver = dev->platform_data;
+	struct isa_dev *isa_dev = to_isa_dev(dev);
+	struct isa_driver *isa_driver = isa_dev->isa_driver;
 
 	if (isa_driver->suspend)
-		return isa_driver->suspend(dev, to_isa_dev(dev)->id, state);
+		return isa_driver->suspend(dev, isa_dev->id, state);
 
 	return 0;
 }
 
 static int isa_bus_resume(struct device *dev)
 {
-	struct isa_driver *isa_driver = dev->platform_data;
+	struct isa_dev *isa_dev = to_isa_dev(dev);
+	struct isa_driver *isa_driver = isa_dev->isa_driver;
 
 	if (isa_driver->resume)
-		return isa_driver->resume(dev, to_isa_dev(dev)->id);
+		return isa_driver->resume(dev, isa_dev->id);
 
 	return 0;
 }
@@ -137,9 +143,9 @@
 		snprintf(isa_dev->dev.bus_id, BUS_ID_SIZE, "%s.%u",
 				isa_driver->driver.name, id);
 
-		isa_dev->dev.platform_data	= isa_driver;
-		isa_dev->dev.release		= isa_dev_release;
-		isa_dev->id			= id;
+		isa_dev->dev.release	= isa_dev_release;
+		isa_dev->isa_driver	= isa_driver;
+		isa_dev->id		= id;
 
 		error = device_register(&isa_dev->dev);
 		if (error) {
@@ -147,7 +153,7 @@
 			break;
 		}
 
-		if (isa_dev->dev.platform_data) {
+		if (isa_dev->isa_driver) {
 			isa_dev->next = isa_driver->devices;
 			isa_driver->devices = &isa_dev->dev;
 		} else

  reply	other threads:[~2006-10-10  5:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-10  3:36 Benjamin Herrenschmidt
2006-10-10  5:48 ` Rene Herman [this message]
2006-10-10  5:57   ` Benjamin Herrenschmidt

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=452B3417.7050106@keyaccess.nl \
    --to=rene.herman@keyaccess.nl \
    --cc=benh@kernel.crashing.org \
    --cc=greg@kroah.com \
    --cc=linux-kernel@vger.kernel.org \
    /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

all inboxes | Powered by JetHome®