scsi_sysfs.c (b485462aca7df4e32bcf7efb6f84a69e8b640243) | scsi_sysfs.c (3b661a92e869ebe2358de8f4b3230ad84f7fce51) |
---|---|
1/* 2 * scsi_sysfs.c 3 * 4 * SCSI sysfs interface routines. 5 * 6 * Created to pull SCSI mid layer sysfs routines into one file. 7 */ 8 --- 991 unchanged lines hidden (view full) --- 1000 1001static void __scsi_remove_target(struct scsi_target *starget) 1002{ 1003 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 1004 unsigned long flags; 1005 struct scsi_device *sdev; 1006 1007 spin_lock_irqsave(shost->host_lock, flags); | 1/* 2 * scsi_sysfs.c 3 * 4 * SCSI sysfs interface routines. 5 * 6 * Created to pull SCSI mid layer sysfs routines into one file. 7 */ 8 --- 991 unchanged lines hidden (view full) --- 1000 1001static void __scsi_remove_target(struct scsi_target *starget) 1002{ 1003 struct Scsi_Host *shost = dev_to_shost(starget->dev.parent); 1004 unsigned long flags; 1005 struct scsi_device *sdev; 1006 1007 spin_lock_irqsave(shost->host_lock, flags); |
1008 starget->reap_ref++; | |
1009 restart: 1010 list_for_each_entry(sdev, &shost->__devices, siblings) { 1011 if (sdev->channel != starget->channel || 1012 sdev->id != starget->id || 1013 scsi_device_get(sdev)) 1014 continue; 1015 spin_unlock_irqrestore(shost->host_lock, flags); 1016 scsi_remove_device(sdev); 1017 scsi_device_put(sdev); 1018 spin_lock_irqsave(shost->host_lock, flags); 1019 goto restart; 1020 } 1021 spin_unlock_irqrestore(shost->host_lock, flags); | 1008 restart: 1009 list_for_each_entry(sdev, &shost->__devices, siblings) { 1010 if (sdev->channel != starget->channel || 1011 sdev->id != starget->id || 1012 scsi_device_get(sdev)) 1013 continue; 1014 spin_unlock_irqrestore(shost->host_lock, flags); 1015 scsi_remove_device(sdev); 1016 scsi_device_put(sdev); 1017 spin_lock_irqsave(shost->host_lock, flags); 1018 goto restart; 1019 } 1020 spin_unlock_irqrestore(shost->host_lock, flags); |
1022 scsi_target_reap(starget); | |
1023} 1024 | 1021} 1022 |
1025static int __remove_child (struct device * dev, void * data) 1026{ 1027 if (scsi_is_target_device(dev)) 1028 __scsi_remove_target(to_scsi_target(dev)); 1029 return 0; 1030} 1031 | |
1032/** 1033 * scsi_remove_target - try to remove a target and all its devices 1034 * @dev: generic starget or parent of generic stargets to be removed 1035 * 1036 * Note: This is slightly racy. It is possible that if the user 1037 * requests the addition of another device then the target won't be 1038 * removed. 1039 */ 1040void scsi_remove_target(struct device *dev) 1041{ | 1023/** 1024 * scsi_remove_target - try to remove a target and all its devices 1025 * @dev: generic starget or parent of generic stargets to be removed 1026 * 1027 * Note: This is slightly racy. It is possible that if the user 1028 * requests the addition of another device then the target won't be 1029 * removed. 1030 */ 1031void scsi_remove_target(struct device *dev) 1032{ |
1042 if (scsi_is_target_device(dev)) { 1043 __scsi_remove_target(to_scsi_target(dev)); 1044 return; | 1033 struct Scsi_Host *shost = dev_to_shost(dev->parent); 1034 struct scsi_target *starget, *found; 1035 unsigned long flags; 1036 1037 restart: 1038 found = NULL; 1039 spin_lock_irqsave(shost->host_lock, flags); 1040 list_for_each_entry(starget, &shost->__targets, siblings) { 1041 if (starget->state == STARGET_DEL) 1042 continue; 1043 if (starget->dev.parent == dev || &starget->dev == dev) { 1044 found = starget; 1045 found->reap_ref++; 1046 break; 1047 } |
1045 } | 1048 } |
1049 spin_unlock_irqrestore(shost->host_lock, flags); |
|
1046 | 1050 |
1047 get_device(dev); 1048 device_for_each_child(dev, NULL, __remove_child); 1049 put_device(dev); | 1051 if (found) { 1052 __scsi_remove_target(found); 1053 scsi_target_reap(found); 1054 /* in the case where @dev has multiple starget children, 1055 * continue removing. 1056 * 1057 * FIXME: does such a case exist? 1058 */ 1059 goto restart; 1060 } |
1050} 1051EXPORT_SYMBOL(scsi_remove_target); 1052 1053int scsi_register_driver(struct device_driver *drv) 1054{ 1055 drv->bus = &scsi_bus_type; 1056 1057 return driver_register(drv); --- 74 unchanged lines hidden --- | 1061} 1062EXPORT_SYMBOL(scsi_remove_target); 1063 1064int scsi_register_driver(struct device_driver *drv) 1065{ 1066 drv->bus = &scsi_bus_type; 1067 1068 return driver_register(drv); --- 74 unchanged lines hidden --- |