This patch (as1248e) changes the meaning of starget->reap_ref. Now it serves to count the number of underlying devices beneath the target (i.e., the length of the starget->devices list), plus one when we want to prevent a possibly-empty target from being removed from visibility. Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> --- Index: usb-2.6/drivers/scsi/scsi_scan.c =================================================================== --- usb-2.6.orig/drivers/scsi/scsi_scan.c +++ usb-2.6/drivers/scsi/scsi_scan.c @@ -305,6 +305,7 @@ static struct scsi_device *scsi_alloc_sd transport_setup_device(&sdev->sdev_gendev); spin_lock_irqsave(shost->host_lock, flags); + starget->reap_ref++; list_add_tail(&sdev->same_target_siblings, &starget->devices); list_add_tail(&sdev->siblings, &shost->__devices); spin_unlock_irqrestore(shost->host_lock, flags); @@ -503,7 +504,7 @@ void scsi_target_reap(struct scsi_target spin_lock_irqsave(shost->host_lock, flags); state = starget->state; - if (--starget->reap_ref == 0 && list_empty(&starget->devices)) { + if (--starget->reap_ref == 0) { empty = 1; starget->state = STARGET_DEL; } Index: usb-2.6/drivers/scsi/scsi_sysfs.c =================================================================== --- usb-2.6.orig/drivers/scsi/scsi_sysfs.c +++ usb-2.6/drivers/scsi/scsi_sysfs.c @@ -305,7 +305,6 @@ static void scsi_device_dev_release_user transport_destroy_device(&sdev->sdev_gendev); spin_lock_irqsave(sdev->host->host_lock, flags); - starget->reap_ref++; list_del(&sdev->siblings); list_del(&sdev->same_target_siblings); list_del(&sdev->starved_entry); -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html