[U-Boot] [U-BOOT][PATCH 3/3] Fix miscalculated total sectors

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; }

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.
participants (2)
-
Jean-Christophe PLAGNIOL-VILLARD
-
unsik Kim