提交 11b9a4d8 编写于 作者: S Stephen Warren 提交者: Tom Rini

sf: fix timebase data type in _wait_ready()

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: 4efad20a ("sf: Update status reg check in spi_flash_cmd_wait_ready")
Signed-off-by: NStephen Warren <swarren@nvidia.com>
Reviewed-by: NTom Rini <trini@konsulko.com>
Reviewed-by: NJagan Teki <jteki@openedev.com>
上级 ef5ebe95
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册