All of lore.kernel.org
 help / color / mirror / Atom feed
From: Che-Liang Chiou <clchiou@chromium.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 1/2] Flatten and solidify block_dev_desc layout
Date: Fri, 21 Oct 2011 14:31:47 +0800	[thread overview]
Message-ID: <1319178708-10881-2-git-send-email-clchiou@chromium.org> (raw)
In-Reply-To: <1319178708-10881-1-git-send-email-clchiou@chromium.org>

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 <clchiou@chromium.org>
---
 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

  reply	other threads:[~2011-10-21  6:31 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-21  6:31 [U-Boot] [PATCH 0/2] api: extend accessible set of block device attributes Che-Liang Chiou
2011-10-21  6:31 ` Che-Liang Chiou [this message]
2011-10-21 19:09   ` [U-Boot] [PATCH 1/2] Flatten and solidify block_dev_desc layout Wolfgang Denk
2011-10-24  3:36     ` Che-liang Chiou
2011-10-24 10:49       ` Detlev Zundel
2011-10-21  6:31 ` [U-Boot] [PATCH 2/2] api: storage: Share attributes with block_dev_desc Che-Liang Chiou
2012-01-08  7:26   ` Mike Frysinger
2011-10-21  7:03 ` [U-Boot] [PATCH 1/2] Flatten and solidify block_dev_desc layout Che-Liang Chiou
2011-10-21 16:06 ` [U-Boot] [PATCH 0/2] api: extend accessible set of block device attributes Detlev Zundel
2011-10-24  3:36   ` Che-liang Chiou
2011-10-24  9:32     ` Detlev Zundel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1319178708-10881-2-git-send-email-clchiou@chromium.org \
    --to=clchiou@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.