]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
fat: cannot compare bytes and sectors
authorSergei Shtylyov <sshtylyov@ru.mvista.com>
Mon, 8 Aug 2011 09:39:29 +0000 (09:39 +0000)
committerWolfgang Denk <wd@denx.de>
Sat, 1 Oct 2011 19:51:23 +0000 (21:51 +0200)
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>
fs/fat/fat.c

index a344469003aff066e686ada6a62ab5603fa3dade..d5aded420d535627e54002d2e18b5d89d31406bd 100644 (file)
@@ -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;