From e27720e6888425e65a4a91cb7e332020579c6935 Mon Sep 17 00:00:00 2001 From: Liu Aleaxander Date: Wed, 24 Jun 2009 06:44:11 +0800 Subject: [PATCH] Core: fixs the chunk>>=1 problem well, it seems ugly, but it can do the right work(I think). here is the new way: chunk = chunk == 1 ? 0 : ((chunk+1) >> 1); if we are reading ONE sector, and after six retries, we can mark it as _failed_. So just make it be ZERO. --- core/diskio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/diskio.c b/core/diskio.c index 28aac10..bb5b34c 100644 --- a/core/diskio.c +++ b/core/diskio.c @@ -73,7 +73,9 @@ static int chs_rdwr_sectors(struct disk *disk, void *buf, break; if (retry--) continue; - chunk >>= 1; + + /* if we are reading ONE sector and go here, just make it _faile_ */ + chunk = chunk == 1 ? 0 : ((chunk+1) >> 1); if (chunk) { MaxTransfer = chunk; retry = RETRY_COUNT; @@ -158,7 +160,7 @@ static int edd_rdwr_sectors(struct disk *disk, void *buf, break; if (retry--) continue; - chunk >>= 1; + chunk = chunk == 1 ? 0 : ((chunk+1) >> 1); if (chunk) { MaxTransfer = chunk; retry = RETRY_COUNT; -- 2.7.4