]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
sf: fix timebase data type in _wait_ready()
authorStephen Warren <swarren@nvidia.com>
Mon, 4 Apr 2016 17:03:52 +0000 (11:03 -0600)
committerTom Rini <trini@konsulko.com>
Mon, 25 Apr 2016 19:10:30 +0000 (15:10 -0400)
get_timer() returns an unsigned 64-bit value, but is currently assigned to
a signed 32-bit variable. Due to sign extension and data truncation, this
causes the timeout loop in spi_flash_cmd_wait_ready() to immediately (and
incorrectly) fire for about 50% of all time values, based on whether bit
31 is set. In sandbox at least, this causes the test to pass or fail based
on system uptime, as opposed to time since the U-Boot binary was started.

Fixes: 4efad20a1751 ("sf: Update status reg check in spi_flash_cmd_wait_ready")
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
Reviewed-by: Jagan Teki <jteki@openedev.com>
drivers/mtd/spi/spi_flash.c

index 44d9e9ba01056aacaae85918925bb893144e6f7e..5451725689493d154ed59ed7ab2c2118672b9c02 100644 (file)
@@ -265,7 +265,8 @@ static int spi_flash_ready(struct spi_flash *flash)
 static int spi_flash_cmd_wait_ready(struct spi_flash *flash,
                                        unsigned long timeout)
 {
-       int timebase, ret;
+       unsigned long timebase;
+       int ret;
 
        timebase = get_timer(0);