Skip to content

Commit

Permalink
[PATCH] Use device_for_each_child() to unregister devices in scsi_rem…
Browse files Browse the repository at this point in the history
…ove_target().

Signed-off-by: Patrick Mochel <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>

Index: gregkh-2.6/drivers/scsi/scsi_sysfs.c
===================================================================
  • Loading branch information
[email protected] authored and gregkh committed Jun 20, 2005
1 parent 0293a50 commit 20b1e67
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/scsi/scsi_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,13 @@ void __scsi_remove_target(struct scsi_target *starget)
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
Expand All @@ -679,18 +686,15 @@ void __scsi_remove_target(struct scsi_target *starget)
*/
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));
return;
}

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);
Expand Down

0 comments on commit 20b1e67

Please sign in to comment.