Fix miscalculated total sectors
PATCH 3/3 Fix miscalculated total sectors
When using CONFIG_MG_DISK_RES, total sectors should be recalculated.
Signed-off-by unsik Kim <[email protected]>
--- drivers/block/mg_disk.c | 18 ++++++++++++++---- 1 files changed, 14 insertions(+), 4 deletions(-)
drivers/block/mg_disk.c +14 -4
@@ -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 ; }
Signature · 1 line
1.5.6.6
PATCH 3/3 Fix miscalculated total sectors
Quoted 4 lines · unsik Kim
When using
CONFIG_MG_DISK_RES, total sectors should be recalculated.Signed-off-by unsik Kim <[email protected]>
same as patch 2 why in an other patch?
Best Regards,
J.