public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [U-Boot] [U-BOOT][PATCH 3/3] Fix miscalculated total sectors
@ 2009-02-13 11:05 unsik Kim
  2009-02-14 11:53 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 1 reply; 2+ messages in thread
From: unsik Kim @ 2009-02-13 11:05 UTC (permalink / raw)
  To: u-boot

When using CONFIG_MG_DISK_RES, total sectors should be
recalculated.

Signed-off-by: unsik Kim <donari75@gmail.com>
---
 drivers/block/mg_disk.c |   18 ++++++++++++++----
 1 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/block/mg_disk.c b/drivers/block/mg_disk.c
index e1b1a68..193a441 100644
--- a/drivers/block/mg_disk.c
+++ b/drivers/block/mg_disk.c
@@ -174,7 +174,7 @@ static int mg_get_disk_id (void)
 {
 	u32 iobuf[(MG_SECTOR_SIZE / sizeof(u32))];
 	hd_driveid_t *iop = (hd_driveid_t *)iobuf;
-	u32 i, err;
+	u32 i, err, res;
 	u16 *buff = (u16 *)iobuf;
 
 	writeb(MG_CMD_ID, MG_BASE + MG_REG_COMMAND);
@@ -214,11 +214,21 @@ static int mg_get_disk_id (void)
 #endif /* __LITTLE_ENDIAN */
 
 #ifdef __BIG_ENDIAN
-	mg_disk_dev.lba = (iop->lba_capacity << 16) | (iop->lba_capacity >> 16);
-#else	/* ! __BIG_ENDIAN */
-	mg_disk_dev.lba = iop->lba_capacity;
+	iop->lba_capacity = (iop->lba_capacity << 16) |
+		(iop->lba_capacity >> 16);
 #endif /* __BIG_ENDIAN */
 
+	if (MG_RES_SEC) {
+		MG_DBG("MG_RES_SEC=%d\n", MG_RES_SEC);
+		iop->cyls = (iop->lba_capacity - MG_RES_SEC) /
+			iop->sectors / iop->heads;
+		res = iop->lba_capacity -
+			iop->cyls * iop->heads * iop->sectors;
+		iop->lba_capacity -= res;
+		printf("mg_disk: %d sectors reserved\n", res);
+	}
+
+	mg_disk_dev.lba = iop->lba_capacity;
 	return MG_ERR_NONE;
 }
 
-- 
1.5.6.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [U-BOOT][PATCH 3/3] Fix miscalculated total sectors
  2009-02-13 11:05 [U-Boot] [U-BOOT][PATCH 3/3] Fix miscalculated total sectors unsik Kim
@ 2009-02-14 11:53 ` Jean-Christophe PLAGNIOL-VILLARD
  0 siblings, 0 replies; 2+ messages in thread
From: Jean-Christophe PLAGNIOL-VILLARD @ 2009-02-14 11:53 UTC (permalink / raw)
  To: u-boot

On 20:05 Fri 13 Feb     , unsik Kim wrote:
> When using CONFIG_MG_DISK_RES, total sectors should be
> recalculated.
> 
> Signed-off-by: unsik Kim <donari75@gmail.com>
same as patch 2 why in an other patch?

Best Regards,
J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-02-14 11:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-13 11:05 [U-Boot] [U-BOOT][PATCH 3/3] Fix miscalculated total sectors unsik Kim
2009-02-14 11:53 ` Jean-Christophe PLAGNIOL-VILLARD

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox