diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | 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 index e75ee4671ee3..7134618f0a1f 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c | |||
@@ -669,6 +669,13 @@ void __scsi_remove_target(struct scsi_target *starget) | |||
669 | scsi_target_reap(starget); | 669 | scsi_target_reap(starget); |
670 | } | 670 | } |
671 | 671 | ||
672 | static int __remove_child (struct device * dev, void * data) | ||
673 | { | ||
674 | if (scsi_is_target_device(dev)) | ||
675 | __scsi_remove_target(to_scsi_target(dev)); | ||
676 | return 0; | ||
677 | } | ||
678 | |||
672 | /** | 679 | /** |
673 | * scsi_remove_target - try to remove a target and all its devices | 680 | * scsi_remove_target - try to remove a target and all its devices |
674 | * @dev: generic starget or parent of generic stargets to be removed | 681 | * @dev: generic starget or parent of generic stargets to be removed |
@@ -679,7 +686,7 @@ void __scsi_remove_target(struct scsi_target *starget) | |||
679 | */ | 686 | */ |
680 | void scsi_remove_target(struct device *dev) | 687 | void scsi_remove_target(struct device *dev) |
681 | { | 688 | { |
682 | struct device *rdev, *idev, *next; | 689 | struct device *rdev; |
683 | 690 | ||
684 | if (scsi_is_target_device(dev)) { | 691 | if (scsi_is_target_device(dev)) { |
685 | __scsi_remove_target(to_scsi_target(dev)); | 692 | __scsi_remove_target(to_scsi_target(dev)); |
@@ -687,10 +694,7 @@ void scsi_remove_target(struct device *dev) | |||
687 | } | 694 | } |
688 | 695 | ||
689 | rdev = get_device(dev); | 696 | rdev = get_device(dev); |
690 | list_for_each_entry_safe(idev, next, &dev->children, node) { | 697 | device_for_each_child(dev, NULL, __remove_child); |
691 | if (scsi_is_target_device(idev)) | ||
692 | __scsi_remove_target(to_scsi_target(idev)); | ||
693 | } | ||
694 | put_device(rdev); | 698 | put_device(rdev); |
695 | } | 699 | } |
696 | EXPORT_SYMBOL(scsi_remove_target); | 700 | EXPORT_SYMBOL(scsi_remove_target); |