diff options
author | Sergei Shtylyov <sshtylyov@ru.mvista.com> | 2011-08-08 09:39:29 (GMT) |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2011-10-01 19:51:23 (GMT) |
commit | 60b36f0fc7c77e98b9d55c237e455c42a1caa44b (patch) | |
tree | 2427ebadc4ad1964c7d45a1ea3383910dcd5db40 /fs/fat | |
parent | ac4977719e157bcb3c45c70d9dd781164727530d (diff) | |
download | u-boot-fsl-qoriq-60b36f0fc7c77e98b9d55c237e455c42a1caa44b.tar.xz |
fat: cannot compare bytes and sectors
The code multiples the FAT size in sectors by the sector size and then tries to
compare that to the number of sectors in the 'getsize' variable. While fixing
this, also change the initial value of 'getsize' as the division of FATBUFSIZE
by the sector size gets us FATBUFBLOCKS.
Signed-off-by: Sergei Shtylyov <sshtylyov@mvista.com>
Diffstat (limited to 'fs/fat')
-rw-r--r-- | fs/fat/fat.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/fat/fat.c b/fs/fat/fat.c index a344469..d5aded4 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -209,16 +209,17 @@ static __u32 get_fatent (fsdata *mydata, __u32 entry) /* Read a new block of FAT entries into the cache. */ if (bufnum != mydata->fatbufnum) { - __u32 getsize = FATBUFSIZE / mydata->sect_size; + __u32 getsize = FATBUFBLOCKS; __u8 *bufptr = mydata->fatbuf; __u32 fatlength = mydata->fatlength; __u32 startblock = bufnum * FATBUFBLOCKS; + if (getsize > fatlength) + getsize = fatlength; + fatlength *= mydata->sect_size; /* We want it in bytes now */ startblock += mydata->fat_sect; /* Offset from start of disk */ - if (getsize > fatlength) - getsize = fatlength; if (disk_read(startblock, getsize, bufptr) < 0) { debug("Error reading FAT blocks\n"); return ret; |