Skip to contentSkip to conversation

scsi_debug: Convert to use root_device_register() and root_device_unregister()

PATCH In review Nicholas A. Bellinger 4 participants 5 messages Sep 7, 2010 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 scsi_debug: Convert to use root_device_register() and root_device_unregister()

From: Nicholas Bellinger <[email protected]>

Hi Doug and Co,

This patch updates the scsi_debug virtual LLD to use root_device_register() and root_device_unregister() from include/linux/device.h instead of device_register() and device_unregister() respectively within scsi_debug_init() and scsi_debug_exit() This simply involved converting the static struct device pseudo_primary into a pointer that is setup by the call to root_device_register().

This patch also contains the correct IS_ERR() conditional check of root_device_register() from within scsi_debug_init().

Thanks to Richard Sharpe and Dmitry Torokhov for their help with this item.

---
 drivers/scsi/scsi_debug.c |   25 ++++++++-----------------
 1 files changed, 8 insertions(+), 17 deletions(-)
drivers/scsi/scsi_debug.c +8 -17
index b02bdc6..6047c10 100644
@@ -3207,16 +3207,7 @@ static void do_remove_driverfs_files(void)
 	driver_remove_file(&sdebug_driverfs_driver, &driver_attr_add_host);
 }
 
-static void pseudo_0_release(struct device *dev)
-{
-	if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
-		printk(KERN_INFO "scsi_debug: pseudo_0_release() called\n");
-}
-
-static struct device pseudo_primary = {
-	.init_name	= "pseudo_0",
-	.release	= pseudo_0_release,
-};
+struct device *pseudo_primary;
 
 static int __init scsi_debug_init(void)
 {
@@ -3352,10 +3343,10 @@ static int __init scsi_debug_init(void)
 			map_region(0, 2);
 	}
 
-	ret = device_register(&pseudo_primary);
-	if (ret < 0) {
-		printk(KERN_WARNING "scsi_debug: device_register error: %d\n",
-			ret);
+	pseudo_primary = root_device_register("pseudo_0");
+	if (IS_ERR(pseudo_primary)) {
+		printk(KERN_WARNING "scsi_debug: root_device_register() error\n");
+		ret = PTR_ERR(pseudo_primary);
 		goto free_vm;
 	}
 	ret = bus_register(&pseudo_lld_bus);
@@ -3402,7 +3393,7 @@ del_files:
 bus_unreg:
 	bus_unregister(&pseudo_lld_bus);
 dev_unreg:
-	device_unregister(&pseudo_primary);
+	root_device_unregister(pseudo_primary);
 free_vm:
 	if (map_storep)
 		vfree(map_storep);
@@ -3423,7 +3414,7 @@ static void __exit scsi_debug_exit(void)
 	do_remove_driverfs_files();
 	driver_unregister(&sdebug_driverfs_driver);
 	bus_unregister(&pseudo_lld_bus);
-	device_unregister(&pseudo_primary);
+	root_device_unregister(pseudo_primary);
 
 	if (dif_storep)
 		vfree(dif_storep);
@@ -3474,7 +3465,7 @@ static int sdebug_add_adapter(void)
         spin_unlock(&sdebug_host_list_lock);
 
         sdbg_host->dev.bus = &pseudo_lld_bus;
-        sdbg_host->dev.parent = &pseudo_primary;
+        sdbg_host->dev.parent = pseudo_primary;
         sdbg_host->dev.release = &sdebug_release_adapter;
         dev_set_name(&sdbg_host->dev, "adapter%d", scsi_debug_add_host);
 
Signature · 1 line
1.5.6.5
Acked-by on v3 1/1
#1 lore raw
Quoted 10 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

Hi Doug and Co,

This patch updates the scsi_debug virtual LLD to use root_device_register() and root_device_unregister() from include/linux/device.h instead of device_register() and device_unregister() respectively within scsi_debug_init() and scsi_debug_exit() This simply involved converting the static struct device pseudo_primary into a pointer that is setup by the call to root_device_register().

Quoted 6 lines

This patch also contains the correct IS_ERR() conditional check of root_device_register() from within scsi_debug_init().

Thanks to Richard Sharpe and Dmitry Torokhov for their help with this item.

Thanks for making the changes.

Quoted 71 lines
---
 drivers/scsi/scsi_debug.c |   25 ++++++++-----------------
 1 files changed, 8 insertions(+), 17 deletions(-)
drivers/scsi/scsi_debug.c +8 -17
index b02bdc6..6047c10 100644
@@ -3207,16 +3207,7 @@ static void do_remove_driverfs_files(void)
 	driver_remove_file(&sdebug_driverfs_driver, &driver_attr_add_host);
 }
 
-static void pseudo_0_release(struct device *dev)
-{
-	if (SCSI_DEBUG_OPT_NOISE & scsi_debug_opts)
-		printk(KERN_INFO "scsi_debug: pseudo_0_release() called\n");
-}
-
-static struct device pseudo_primary = {
-	.init_name	= "pseudo_0",
-	.release	= pseudo_0_release,
-};
+struct device *pseudo_primary;
 
 static int __init scsi_debug_init(void)
 {
@@ -3352,10 +3343,10 @@ static int __init scsi_debug_init(void)
 			map_region(0, 2);
 	}
 
-	ret = device_register(&pseudo_primary);
-	if (ret < 0) {
-		printk(KERN_WARNING "scsi_debug: device_register error: %d\n",
-			ret);
+	pseudo_primary = root_device_register("pseudo_0");
+	if (IS_ERR(pseudo_primary)) {
+		printk(KERN_WARNING "scsi_debug: root_device_register() error\n");
+		ret = PTR_ERR(pseudo_primary);
 		goto free_vm;
 	}
 	ret = bus_register(&pseudo_lld_bus);
@@ -3402,7 +3393,7 @@ del_files:
 bus_unreg:
 	bus_unregister(&pseudo_lld_bus);
 dev_unreg:
-	device_unregister(&pseudo_primary);
+	root_device_unregister(pseudo_primary);
 free_vm:
 	if (map_storep)
 		vfree(map_storep);
@@ -3423,7 +3414,7 @@ static void __exit scsi_debug_exit(void)
 	do_remove_driverfs_files();
 	driver_unregister(&sdebug_driverfs_driver);
 	bus_unregister(&pseudo_lld_bus);
-	device_unregister(&pseudo_primary);
+	root_device_unregister(pseudo_primary);
 
 	if (dif_storep)
 		vfree(dif_storep);
@@ -3474,7 +3465,7 @@ static int sdebug_add_adapter(void)
         spin_unlock(&sdebug_host_list_lock);
 
         sdbg_host->dev.bus = &pseudo_lld_bus;
-        sdbg_host->dev.parent = &pseudo_primary;
+        sdbg_host->dev.parent = pseudo_primary;
         sdbg_host->dev.release = &sdebug_release_adapter;
         dev_set_name(&sdbg_host->dev, "adapter%d", scsi_debug_add_host);
 
Signature · 1 line
1.5.6.5
Signature · 1 line
Dmitry
#2 lore raw
Quoted 14 lines · Dmitry Torokhov
Quoted 13 lines · Nicholas A. Bellinger

From: Nicholas Bellinger<[email protected]>

Hi Doug and Co,

This patch updates the scsi_debug virtual LLD to use root_device_register() and root_device_unregister() from include/linux/device.h instead of device_register() and device_unregister() respectively within scsi_debug_init() and scsi_debug_exit() This simply involved converting the static struct device pseudo_primary into a pointer that is setup by the call to root_device_register().

This patch also contains the correct IS_ERR() conditional check of root_device_register() from within scsi_debug_init().

Quoted 7 lines
Quoted 3 lines

Thanks to Richard Sharpe and Dmitry Torokhov for their help with this item.

Thanks for making the changes.

Quoted 72 lines
Quoted 71 lines
---
  drivers/scsi/scsi_debug.c |   25 ++++++++-----------------
  1 files changed, 8 insertions(+), 17 deletions(-)
drivers/scsi/scsi_debug.c +8 -18
index b02bdc6..6047c10 100644
@@ -3207,16 +3207,7 @@ static void do_remove_driverfs_files(void)
  	driver_remove_file(&sdebug_driverfs_driver,&driver_attr_add_host);
  }
 
-static void pseudo_0_release(struct device *dev)
-{
-	if (SCSI_DEBUG_OPT_NOISE&  scsi_debug_opts)
-		printk(KERN_INFO "scsi_debug: pseudo_0_release() called\n");
-}
-
-static struct device pseudo_primary = {
-	.init_name	= "pseudo_0",
-	.release	= pseudo_0_release,
-};
+struct device *pseudo_primary;
 
  static int __init scsi_debug_init(void)
  {
@@ -3352,10 +3343,10 @@ static int __init scsi_debug_init(void)
  			map_region(0, 2);
  	}
 
-	ret = device_register(&pseudo_primary);
-	if (ret<  0) {
-		printk(KERN_WARNING "scsi_debug: device_register error: %d\n",
-			ret);
+	pseudo_primary = root_device_register("pseudo_0");
+	if (IS_ERR(pseudo_primary)) {
+		printk(KERN_WARNING "scsi_debug: root_device_register() error\n");
+		ret = PTR_ERR(pseudo_primary);
  		goto free_vm;
  	}
  	ret = bus_register(&pseudo_lld_bus);
@@ -3402,7 +3393,7 @@ del_files:
  bus_unreg:
  	bus_unregister(&pseudo_lld_bus);
  dev_unreg:
-	device_unregister(&pseudo_primary);
+	root_device_unregister(pseudo_primary);
  free_vm:
  	if (map_storep)
  		vfree(map_storep);
@@ -3423,7 +3414,7 @@ static void __exit scsi_debug_exit(void)
  	do_remove_driverfs_files();
  	driver_unregister(&sdebug_driverfs_driver);
  	bus_unregister(&pseudo_lld_bus);
-	device_unregister(&pseudo_primary);
+	root_device_unregister(pseudo_primary);
 
  	if (dif_storep)
  		vfree(dif_storep);
@@ -3474,7 +3465,7 @@ static int sdebug_add_adapter(void)
          spin_unlock(&sdebug_host_list_lock);
 
          sdbg_host->dev.bus =&pseudo_lld_bus;
-        sdbg_host->dev.parent =&pseudo_primary;
+        sdbg_host->dev.parent = pseudo_primary;
          sdbg_host->dev.release =&sdebug_release_adapter;
          dev_set_name(&sdbg_host->dev, "adapter%d", scsi_debug_add_host);
 
--

1.5.6.5

#3 lore raw
In reply to Dmitry Torokhov
Quoted 14 lines · Dmitry Torokhov
Quoted 13 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

Hi Doug and Co,

This patch updates the scsi_debug virtual LLD to use root_device_register() and root_device_unregister() from include/linux/device.h instead of device_register() and device_unregister() respectively within scsi_debug_init() and scsi_debug_exit() This simply involved converting the static struct device pseudo_primary into a pointer that is setup by the call to root_device_register().

This patch also contains the correct IS_ERR() conditional check of root_device_register() from within scsi_debug_init().

Quoted 7 lines
Quoted 3 lines

Thanks to Richard Sharpe and Dmitry Torokhov for their help with this item.

Thanks for making the changes.

Can I make that Reviewed-by:? Acked-by is really just for maintainer patches which don't warrant a signoff.

James

#4 lore raw
Quoted 17 lines · James Bottomley
Quoted 16 lines · Dmitry Torokhov
Quoted 15 lines · Nicholas A. Bellinger

From: Nicholas Bellinger <[email protected]>

Hi Doug and Co,

This patch updates the scsi_debug virtual LLD to use root_device_register() and root_device_unregister() from include/linux/device.h instead of device_register() and device_unregister() respectively within scsi_debug_init() and scsi_debug_exit() This simply involved converting the static struct device pseudo_primary into a pointer that is setup by the call to root_device_register().

This patch also contains the correct IS_ERR() conditional check of root_device_register() from within scsi_debug_init().

Thanks to Richard Sharpe and Dmitry Torokhov for their help with this item.

Quoted 9 lines
Quoted 5 lines
Quoted 1 line

Thanks for making the changes.

Can I make that Reviewed-by:? Acked-by is really just for maintainer patches which don't warrant a signoff.

Sure, whatever suits better.

Signature · 1 line
Dmitry