usb: ehci-mx6: Fix bus enumeration for iMX7 SoCs
[oweals/u-boot.git] / drivers / scsi / scsi.c
index 1a65a3f9b943b58667da497b5b81526ced1c94e4..48cb2a2818bc8dff58b864db86fabcbbf88a548d 100644 (file)
@@ -1,13 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2001
  * Denis Peter, MPL AG Switzerland
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
 #include <dm.h>
-#include <inttypes.h>
+#include <env.h>
 #include <pci.h>
 #include <scsi.h>
 #include <dm/device-internal.h>
@@ -197,7 +196,7 @@ static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr,
                        blks = 0;
                }
                debug("scsi_read_ext: startblk " LBAF
-                     ", blccnt %x buffer %" PRIXPTR "\n",
+                     ", blccnt %x buffer %lX\n",
                      start, smallblks, buf_addr);
                if (scsi_exec(bdev, pccb)) {
                        scsi_print_error(pccb);
@@ -207,7 +206,7 @@ static ulong scsi_read(struct blk_desc *block_dev, lbaint_t blknr,
                buf_addr += pccb->datalen;
        } while (blks != 0);
        debug("scsi_read_ext: end startblk " LBAF
-             ", blccnt %x buffer %" PRIXPTR "\n", start, smallblks, buf_addr);
+             ", blccnt %x buffer %lX\n", start, smallblks, buf_addr);
        return blkcnt;
 }
 
@@ -261,7 +260,7 @@ static ulong scsi_write(struct blk_desc *block_dev, lbaint_t blknr,
                        start += blks;
                        blks = 0;
                }
-               debug("%s: startblk " LBAF ", blccnt %x buffer %" PRIXPTR "\n",
+               debug("%s: startblk " LBAF ", blccnt %x buffer %lx\n",
                      __func__, start, smallblks, buf_addr);
                if (scsi_exec(bdev, pccb)) {
                        scsi_print_error(pccb);
@@ -270,7 +269,7 @@ static ulong scsi_write(struct blk_desc *block_dev, lbaint_t blknr,
                }
                buf_addr += pccb->datalen;
        } while (blks != 0);
-       debug("%s: end startblk " LBAF ", blccnt %x buffer %" PRIXPTR "\n",
+       debug("%s: end startblk " LBAF ", blccnt %x buffer %lX\n",
              __func__, start, smallblks, buf_addr);
        return blkcnt;
 }
@@ -580,7 +579,7 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
        */
        snprintf(str, sizeof(str), "id%dlun%d", id, lun);
        ret = blk_create_devicef(dev, "scsi_blk", str, IF_TYPE_SCSI, -1,
-                       bd.blksz, bd.blksz * bd.lba, &bdev);
+                       bd.blksz, bd.lba, &bdev);
        if (ret) {
                debug("Can't create device\n");
                return ret;
@@ -594,10 +593,9 @@ static int do_scsi_scan_one(struct udevice *dev, int id, int lun, bool verbose)
        memcpy(&bdesc->vendor, &bd.vendor, sizeof(bd.vendor));
        memcpy(&bdesc->product, &bd.product, sizeof(bd.product));
        memcpy(&bdesc->revision, &bd.revision,  sizeof(bd.revision));
-       part_init(bdesc);
 
        if (verbose) {
-               printf("  Device %d: ", 0);
+               printf("  Device %d: ", bdesc->devnum);
                dev_print(bdesc);
        }
        return 0;
@@ -662,15 +660,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 */