summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPragnesh Patel <pragnesh.patel@sifive.com>2020-06-29 15:17:24 +0530
committerPeng Fan <peng.fan@nxp.com>2020-07-14 16:19:39 +0800
commit3ba1d53c420c321a72312902b735680491988bad (patch)
tree4308c4bea08eb3e25227a7a3e5ae95bbfa5efb8e
parent497c7598c4e713eb9ad88fd7963e57b21b8b35e1 (diff)
downloadu-boot-3ba1d53c420c321a72312902b735680491988bad.tar.gz
mmc: mmc_spi: correct the while condition
When variable i will become 0, while(i--) loop breaks but variable i will again decrement to -1 because of i-- and that's why below condition "if (!i && (r != resp_match_value)" will never execute, So doing "i--" inside of while() loop solves this problem. Signed-off-by: Pragnesh Patel <pragnesh.patel@sifive.com> Reviewed-by: Bin Meng <bin.meng@windriver.com> Tested-by: Bin Meng <bin.meng@windriver.com>
-rw-r--r--drivers/mmc/mmc_spi.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/mmc/mmc_spi.c b/drivers/mmc/mmc_spi.c
index e76ab54838..86cc932151 100644
--- a/drivers/mmc/mmc_spi.c
+++ b/drivers/mmc/mmc_spi.c
@@ -105,12 +105,14 @@ static int mmc_spi_sendcmd(struct udevice *dev,
if (resp_match) {
r = ~resp_match_value;
i = CMD_TIMEOUT;
- while (i--) {
+ while (i) {
ret = dm_spi_xfer(dev, 1 * 8, NULL, &r, 0);
if (ret)
return ret;
debug(" resp%d=0x%x", rpos, r);
rpos++;
+ i--;
+
if (r == resp_match_value)
break;
}