]> git.sur5r.net Git - u-boot/commit - fs/fat/fat.c
FIX: fat: Provide correct return code from disk_{read|write} to upper layers
authorŁukasz Majewski <l.majewski@samsung.com>
Thu, 3 Sep 2015 12:21:39 +0000 (14:21 +0200)
committerTom Rini <trini@konsulko.com>
Fri, 11 Sep 2015 21:15:21 +0000 (17:15 -0400)
commit0a04ed86cfaa36d93d55016d0b3dc3f06352a2fe
treea0bcdc4c76b1415308f18028c26173a9b4f12738
parentbcd62e72b2a0185f455ac5bac84416b59b294097
FIX: fat: Provide correct return code from disk_{read|write} to upper layers

It is very common that FAT code is using following pattern:
if (disk_{read|write}() < 0)
        return -1;

Up till now the above code was dead, since disk_{read|write) could only
return value >= 0.
As a result some errors from medium layer (i.e. eMMC/SD) were not caught.

The above behavior was caused by block_{read|write|erase} declared at
struct block_dev_desc (@part.h). It returns unsigned long, where 0
indicates error and > 0 indicates that medium operation was correct.

This patch as error regards 0 returned from block_{read|write|erase}
when nr_blocks is grater than zero. Read/Write operation with nr_blocks=0
should return 0 and hence is not considered as an error.

Signed-off-by: Lukasz Majewski <l.majewski@samsung.com>
Test HW: Odroid XU3 - Exynos 5433
fs/fat/fat.c
fs/fat/fat_write.c