All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH] sf: fix timebase data type in _wait_ready()
@ 2016-04-04 17:03 Stephen Warren
  2016-04-05  0:01 ` Tom Rini
  2016-04-26  0:16 ` [U-Boot] " Tom Rini
  0 siblings, 2 replies; 9+ messages in thread
From: Stephen Warren @ 2016-04-04 17:03 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

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>
---
 drivers/mtd/spi/spi_flash.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/spi/spi_flash.c b/drivers/mtd/spi/spi_flash.c
index 44d9e9ba0105..545172568949 100644
--- a/drivers/mtd/spi/spi_flash.c
+++ b/drivers/mtd/spi/spi_flash.c
@@ -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);
 
-- 
2.8.1

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-04-26  0:16 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-04 17:03 [U-Boot] [PATCH] sf: fix timebase data type in _wait_ready() Stephen Warren
2016-04-05  0:01 ` Tom Rini
2016-04-06 11:22   ` Jagan Teki
2016-04-12 15:43     ` Stephen Warren
2016-04-12 16:03       ` Tom Rini
2016-04-21  5:49     ` Stephen Warren
2016-04-25 16:44       ` Stephen Warren
2016-04-25 16:46         ` Tom Rini
2016-04-26  0:16 ` [U-Boot] " Tom Rini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.