Skip to contentSkip to conversation

xen block: remove driver_data direct access of struct device

PATCH In review Greg Kroah-Hartman 4 participants 6 messages Apr 30, 2009

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 xen block: remove driver_data direct access of struct device

From: Greg Kroah-Hartman <[email protected]>

In the near future, the driver core is going to not allow direct access to the driver_data pointer in struct device. Instead, the functions dev_get_drvdata() and dev_set_drvdata() should be used. These functions have been around since the beginning, so are backwards compatible with all older kernel versions.

---
 drivers/block/xen-blkfront.c |   14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/block/xen-blkfront.c +7 -7
@@ -755,12 +755,12 @@ static int blkfront_probe(struct xenbus_
 
 	/* Front end dir is a number, which is used as the id. */
 	info->handle = simple_strtoul(strrchr(dev->nodename, '/')+1, NULL, 0);
-	dev->dev.driver_data = info;
+	dev_det_drvdata(&dev->dev, info);
 
 	err = talk_to_backend(dev, info);
 	if (err) {
 		kfree(info);
-		dev->dev.driver_data = NULL;
+		dev_det_drvdata(&dev->dev, NULL);
 		return err;
 	}
 
@@ -845,7 +845,7 @@ static int blkif_recover(struct blkfront
  */
 static int blkfront_resume(struct xenbus_device *dev)
 {
-	struct blkfront_info *info = dev->dev.driver_data;
+	struct blkfront_info *info = dev_get_drvdata(&dev->dev);
 	int err;
 
 	dev_dbg(&dev->dev, "blkfront_resume: %s\n", dev->nodename);
@@ -924,7 +924,7 @@ static void blkfront_connect(struct blkf
  */
 static void blkfront_closing(struct xenbus_device *dev)
 {
-	struct blkfront_info *info = dev->dev.driver_data;
+	struct blkfront_info *info = dev_get_drvdata(&dev->dev);
 	unsigned long flags;
 
 	dev_dbg(&dev->dev, "blkfront_closing: %s removed\n", dev->nodename);
@@ -959,7 +959,7 @@ static void blkfront_closing(struct xenb
 static void backend_changed(struct xenbus_device *dev,
 			    enum xenbus_state backend_state)
 {
-	struct blkfront_info *info = dev->dev.driver_data;
+	struct blkfront_info *info = dev_get_drvdata(&dev->dev);
 	struct block_device *bd;
 
 	dev_dbg(&dev->dev, "blkfront:backend_changed.\n");
@@ -997,7 +997,7 @@ static void backend_changed(struct xenbu
 
 static int blkfront_remove(struct xenbus_device *dev)
 {
-	struct blkfront_info *info = dev->dev.driver_data;
+	struct blkfront_info *info = dev_get_drvdata(&dev->dev);
 
 	dev_dbg(&dev->dev, "blkfront_remove: %s removed\n", dev->nodename);
 
@@ -1010,7 +1010,7 @@ static int blkfront_remove(struct xenbus
 
 static int blkfront_is_ready(struct xenbus_device *dev)
 {
-	struct blkfront_info *info = dev->dev.driver_data;
+	struct blkfront_info *info = dev_get_drvdata(&dev->dev);
 
 	return info->is_ready;
 }
Acked-by on v1 1/1
#1 lore raw
Quoted 11 lines · * Greg Kroah-Hartman ([email protected]) wrote:

In the near future, the driver core is going to not allow direct access to the driver_data pointer in struct device. Instead, the functions dev_get_drvdata() and dev_set_drvdata() should be used. These functions have been around since the beginning, so are backwards compatible with all older kernel versions.

after...

drivers/block/xen-blkfront.c static int blkfront_probe(struct xenbus_ · line 763

Quoted 2 lines
drivers/block/xen-blkfront.c +1 -1
-		dev->dev.driver_data = NULL;
+		dev_det_drvdata(&dev->dev, NULL);

...fixing your fingers/script so it compiles ;-)

#2 lore raw
Quoted 7 lines · Chris Wright
Quoted 6 lines · * Greg Kroah-Hartman ([email protected]) wrote:

In the near future, the driver core is going to not allow direct access to the driver_data pointer in struct device. Instead, the functions dev_get_drvdata() and dev_set_drvdata() should be used. These functions have been around since the beginning, so are backwards compatible with all older kernel versions.

Quoted 7 lines
Quoted 5 lines

Thanks, will add it. Any objections for this to go through my driver-core tree to Linus for 2.6.31?

Quoted 6 lines

after...

drivers/block/xen-blkfront.c static int blkfront_probe(struct xenbus_ · line 763

Quoted 2 lines
drivers/block/xen-blkfront.c +1 -1
-		dev->dev.driver_data = NULL;
+		dev_det_drvdata(&dev->dev, NULL);

...fixing your fingers/script so it compiles ;-)

Doh!

And here I thought I had built that one, I guess I hadn't, my mistake. Thanks for catching that, I've now fixed it.

greg k-h

#3 lore raw
Quoted 14 lines · * Greg KH ([email protected]) wrote:
Quoted 13 lines · Chris Wright
Quoted 11 lines · * Greg Kroah-Hartman ([email protected]) wrote:

In the near future, the driver core is going to not allow direct access to the driver_data pointer in struct device. Instead, the functions dev_get_drvdata() and dev_set_drvdata() should be used. These functions have been around since the beginning, so are backwards compatible with all older kernel versions.

Quoted 4 lines
Quoted 1 line

Thanks, will add it. Any objections for this to go through my driver-core tree to Linus for 2.6.31?

None from me.

#5 lore raw
Quoted 7 lines · Jeremy Fitzhardinge
Quoted 6 lines · Chris Wright
Quoted 3 lines · * Greg KH ([email protected]) wrote:

Thanks, will add it. Any objections for this to go through my driver-core tree to Linus for 2.6.31?

Quoted 6 lines
Quoted 2 lines

None from me.

Fine by me.

Thanks, will add this ack and push it myself.

greg k-h