]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
[PATCH] libata-hp-prep: store attached SCSI device
authorTejun Heo <htejun@gmail.com>
Wed, 31 May 2006 09:27:40 +0000 (18:27 +0900)
committerTejun Heo <htejun@gmail.com>
Wed, 31 May 2006 09:27:40 +0000 (18:27 +0900)
Add device persistent field dev->sdev and store the attached SCSI
device.  With hotplug, libata needs to know the attached SCSI device
to offline and detach it, but scsi_device_lookup() cannot be used
because libata will reuse SCSI ID numbers - dead but not gone devices
(due to zombie opens, etc...) interfere with the lookup.

dev->sdev doesn't hold reference to the SCSI device.  It's cleared
when the SCSI device goes away.

Signed-off-by: Tejun Heo <htejun@gmail.com>
drivers/scsi/libata-scsi.c
include/linux/libata.h

index 05090768d9a8b9a7a29db7e201c885969bc12964..da9689b708262c013f6d3660fac8f9144ad6d519 100644 (file)
@@ -2743,16 +2743,22 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd,
 
 void ata_scsi_scan_host(struct ata_port *ap)
 {
-       struct ata_device *dev;
        unsigned int i;
 
        if (ap->flags & ATA_FLAG_DISABLED)
                return;
 
        for (i = 0; i < ATA_MAX_DEVICES; i++) {
-               dev = &ap->device[i];
+               struct ata_device *dev = &ap->device[i];
+               struct scsi_device *sdev;
+
+               if (!ata_dev_enabled(dev) || dev->sdev)
+                       continue;
 
-               if (ata_dev_enabled(dev))
-                       scsi_scan_target(&ap->host->shost_gendev, 0, i, 0, 0);
+               sdev = __scsi_add_device(ap->host, 0, i, 0, NULL);
+               if (!IS_ERR(sdev)) {
+                       dev->sdev = sdev;
+                       scsi_device_put(sdev);
+               }
        }
 }
index 10dc235ad8bc6bfcf4741dcf0d7b957c25d66885..c0513c7527515577301d73d3cf33069b1cf3be2b 100644 (file)
@@ -413,6 +413,7 @@ struct ata_device {
        struct ata_port         *ap;
        unsigned int            devno;          /* 0 or 1 */
        unsigned long           flags;          /* ATA_DFLAG_xxx */
+       struct scsi_device      *sdev;          /* attached SCSI device */
        /* n_sector is used as CLEAR_OFFSET, read comment above CLEAR_OFFSET */
        u64                     n_sectors;      /* size of device, if ATA */
        unsigned int            class;          /* ATA_DEV_xxx */