dm: scsi: report correct device number
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Tue, 5 Feb 2019 17:06:24 +0000 (18:06 +0100)
committerTom Rini <trini@konsulko.com>
Tue, 19 Feb 2019 13:55:43 +0000 (08:55 -0500)
Before the patch scsi would report the same device number for all SCSI
devices, e.g.

  Device 0: (1:0) Vendor: ATA Prod.: Crucial_CT128M55 Rev: MU01
            Type: Hard Disk
            Capacity: 122104.3 MB = 119.2 GB (250069680 x 512)
  Device 0: (1:0) Vendor: ATA Prod.:  Rev:
            Type: Hard Disk
            Capacity: not available

With the patch the same device number is reported as is used in
scsi_read():

  Device 0: (1:0) Vendor: ATA Prod.: Crucial_CT128M55 Rev: MU01
            Type: Hard Disk
            Capacity: 122104.3 MB = 119.2 GB (250069680 x 512)
  Device 1: (1:0) Vendor: ATA Prod.:  Rev:
            Type: Hard Disk
            Capacity: not available

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
drivers/scsi/scsi.c

index df47e2fc78bdc5c611e11a2c952481fda0185ed9..75900d822832ac37883327824a619b2917be5183 100644 (file)
@@ -594,7 +594,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
        memcpy(&bdesc->revision, &bd.revision,  sizeof(bd.revision));
 
        if (verbose) {
-               printf("  Device %d: ", 0);
+               printf("  Device %d: ", bdesc->devnum);
                dev_print(bdesc);
        }
        return 0;
@@ -659,15 +659,16 @@ int scsi_scan(bool verbose)
        scsi_max_devs = 0;
        for (i = 0; i < CONFIG_SYS_SCSI_MAX_SCSI_ID; i++) {
                for (lun = 0; lun < CONFIG_SYS_SCSI_MAX_LUN; lun++) {
-                       ret = scsi_detect_dev(NULL, i, lun,
-                                             &scsi_dev_desc[scsi_max_devs]);
+                       struct blk_desc *bdesc = &scsi_dev_desc[scsi_max_devs];
+
+                       ret = scsi_detect_dev(NULL, i, lun, bdesc);
                        if (ret)
                                continue;
-                       part_init(&scsi_dev_desc[scsi_max_devs]);
+                       part_init(bdesc);
 
                        if (verbose) {
-                               printf("  Device %d: ", 0);
-                               dev_print(&scsi_dev_desc[scsi_max_devs]);
+                               printf("  Device %d: ", bdesc->devnum);
+                               dev_print(bdesc);
                        }
                        scsi_max_devs++;
                } /* next LUN */