The block_dev_desc struct has #ifdef on lba48 and variable-size on lba
and so its layout varies from config to config.  At least part_efi.c has
partially complained about this.

This patch makes lba48 be always defined and lba be fixed to largest
size that an LBA would need so that the block_dev_desc layout would be
an invariant with respect to configurations.

Doing so would waste a few extra bytes per struct block_dev_desc, which
I believe is not critical.

Signed-off-by: Che-Liang Chiou <clch...@chromium.org>
---

Fix a minor checkpatch violation.

 disk/part_dos.c       |    2 +-
 disk/part_efi.c       |    4 +---
 drivers/mmc/mmc.c     |    4 ++--
 drivers/mmc/pxa_mmc.c |    2 +-
 include/part.h        |    4 +---
 5 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/disk/part_dos.c b/disk/part_dos.c
index b5bcb37..a0938db 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -119,7 +119,7 @@ static void print_partition_extended (block_dev_desc_t 
*dev_desc, int ext_part_s
                return;
        }
        if(i==DOS_PBR) {
-               printf ("    1\t\t         0\t%10ld\t%2x\n",
+               printf("    1\t\t         0\t%10lld\t%2x\n",
                        dev_desc->lba, buffer[DOS_PBR_MEDIA_TYPE_OFFSET]);
                return;
        }
diff --git a/disk/part_efi.c b/disk/part_efi.c
index 0a513c6..e779dc1 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -22,10 +22,8 @@
  */
 
 /*
- * Problems with CONFIG_SYS_64BIT_LBA:
- *
  * struct disk_partition.start in include/part.h is sized as ulong.
- * When CONFIG_SYS_64BIT_LBA is activated, lbaint_t changes from ulong to 
uint64_t.
+ * struct block_dev_desc.lba in the same header is sized as uint64_t.
  * For now, it is cast back to ulong at assignment.
  *
  * This limits the maximum size of addressable storage to < 2 Terra Bytes
diff --git a/drivers/mmc/mmc.c b/drivers/mmc/mmc.c
index 391bc2b..c17e495 100644
--- a/drivers/mmc/mmc.c
+++ b/drivers/mmc/mmc.c
@@ -265,7 +265,7 @@ mmc_write_blocks(struct mmc *mmc, ulong start, lbaint_t 
blkcnt, const void*src)
        int timeout = 1000;
 
        if ((start + blkcnt) > mmc->block_dev.lba) {
-               printf("MMC: block number 0x%lx exceeds max(0x%lx)\n",
+               printf("MMC: block number 0x%lx exceeds max(0x%llx)\n",
                        start + blkcnt, mmc->block_dev.lba);
                return 0;
        }
@@ -393,7 +393,7 @@ static ulong mmc_bread(int dev_num, ulong start, lbaint_t 
blkcnt, void *dst)
                return 0;
 
        if ((start + blkcnt) > mmc->block_dev.lba) {
-               printf("MMC: block number 0x%lx exceeds max(0x%lx)\n",
+               printf("MMC: block number 0x%lx exceeds max(0x%llx)\n",
                        start + blkcnt, mmc->block_dev.lba);
                return 0;
        }
diff --git a/drivers/mmc/pxa_mmc.c b/drivers/mmc/pxa_mmc.c
index 48e21ef..67c33d4 100644
--- a/drivers/mmc/pxa_mmc.c
+++ b/drivers/mmc/pxa_mmc.c
@@ -541,7 +541,7 @@ static void mmc_decode_csd(uint32_t * resp)
        mmc_dev.removable = 0;
        mmc_dev.block_read = mmc_bread;
 
-       printf("Detected: %lu blocks of %lu bytes (%luMB) ",
+       printf("Detected: %llu blocks of %lu bytes (%lluMB) ",
                mmc_dev.lba,
                mmc_dev.blksz,
                mmc_dev.lba * mmc_dev.blksz / (1024 * 1024));
diff --git a/include/part.h b/include/part.h
index 1827767..be0a22e 100644
--- a/include/part.h
+++ b/include/part.h
@@ -33,10 +33,8 @@ typedef struct block_dev_desc {
        unsigned char   lun;            /* target LUN */
        unsigned char   type;           /* device type */
        unsigned char   removable;      /* removable device */
-#ifdef CONFIG_LBA48
        unsigned char   lba48;          /* device can use 48bit addr (ATA/ATAPI 
v7) */
-#endif
-       lbaint_t                lba;            /* number of blocks */
+       uint64_t        lba;            /* number of blocks */
        unsigned long   blksz;          /* block size */
        char            vendor [40+1];  /* IDE model, SCSI Vendor */
        char            product[20+1];  /* IDE Serial no, SCSI product */
-- 
1.7.3.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to