[PATCH] Use device_for_each_child() to unregister devices in scsi_remove_target().

From: Greg KH
Date: Mon Jun 20 2005 - 20:24:17 EST


[PATCH] Use device_for_each_child() to unregister devices in scsi_remove_target().

Signed-off-by: Patrick Mochel <mochel@xxxxxxxxxxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

Index: gregkh-2.6/drivers/scsi/scsi_sysfs.c
===================================================================

---
commit 20b1e674230b642be662c5975923a0160ab9cbdc
tree 749e1384c57576bfbe3ffd1414df321cc783296f
parent 0293a509405dccecc30783a5d729d615b68d6a77
author mochel@xxxxxxxxxxxxxxxxxx <mochel@xxxxxxxxxxxxxxxxxx> Thu, 24 Mar 2005 19:03:59 -0800
committer Greg Kroah-Hartman <gregkh@xxxxxxx> Mon, 20 Jun 2005 15:15:19 -0700

drivers/scsi/scsi_sysfs.c | 14 +++++++++-----
1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c
--- a/drivers/scsi/scsi_sysfs.c
+++ b/drivers/scsi/scsi_sysfs.c
@@ -669,6 +669,13 @@ void __scsi_remove_target(struct scsi_ta
scsi_target_reap(starget);
}

+static int __remove_child (struct device * dev, void * data)
+{
+ if (scsi_is_target_device(dev))
+ __scsi_remove_target(to_scsi_target(dev));
+ return 0;
+}
+
/**
* scsi_remove_target - try to remove a target and all its devices
* @dev: generic starget or parent of generic stargets to be removed
@@ -679,7 +686,7 @@ void __scsi_remove_target(struct scsi_ta
*/
void scsi_remove_target(struct device *dev)
{
- struct device *rdev, *idev, *next;
+ struct device *rdev;

if (scsi_is_target_device(dev)) {
__scsi_remove_target(to_scsi_target(dev));
@@ -687,10 +694,7 @@ void scsi_remove_target(struct device *d
}

rdev = get_device(dev);
- list_for_each_entry_safe(idev, next, &dev->children, node) {
- if (scsi_is_target_device(idev))
- __scsi_remove_target(to_scsi_target(idev));
- }
+ device_for_each_child(dev, NULL, __remove_child);
put_device(rdev);
}
EXPORT_SYMBOL(scsi_remove_target);

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/