diff options
author | Wu, Josh <Josh.wu@atmel.com> | 2013-07-24 17:55:30 +0800 |
---|---|---|
committer | Tom Rini <trini@ti.com> | 2013-09-06 13:09:07 -0400 |
commit | 6b8f185faf29db302a20f584cc54253667535f08 (patch) | |
tree | 6e8a65e683845756d20603f2bfd66c7f2de80a3b | |
parent | 7ea50d52849fe8ffa5b5b74c979b60b1045d6fc9 (diff) | |
download | u-boot-imx-6b8f185faf29db302a20f584cc54253667535f08.zip u-boot-imx-6b8f185faf29db302a20f584cc54253667535f08.tar.gz u-boot-imx-6b8f185faf29db302a20f584cc54253667535f08.tar.bz2 |
fs: fat: don't call disk_write with zero sector num
In the set_cluster() function, it will convert the buffer size to sector
numbers. Then call disk_write() to write by sector.
For remaining buffer, the size is less than a sector, call disk_write()
again to write them in one sector.
But if the total buffer size is less then one sector, the original code
will call disk_write() with zero sector number. It is unnecessary.
So this patch fix this. Now it will not call disk_write() if total buffer size
is less than one sector.
Signed-off-by: Josh Wu <josh.wu@atmel.com>
-rw-r--r-- | fs/fat/fat_write.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index b78026a..b7a21e0 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -552,9 +552,11 @@ set_cluster(fsdata *mydata, __u32 clustnum, __u8 *buffer, debug("clustnum: %d, startsect: %d\n", clustnum, startsect); - if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) { - debug("Error writing data\n"); - return -1; + if ((size / mydata->sect_size) > 0) { + if (disk_write(startsect, size / mydata->sect_size, buffer) < 0) { + debug("Error writing data\n"); + return -1; + } } if (size % mydata->sect_size) { |