]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: mmc_spi: correct the while condition
authorPragnesh Patel <pragnesh.patel@sifive.com>
Mon, 29 Jun 2020 09:47:24 +0000 (15:17 +0530)
committerPeng Fan <peng.fan@nxp.com>
Tue, 14 Jul 2020 08:19:39 +0000 (16:19 +0800)
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>
drivers/mmc/mmc_spi.c

index e76ab54838be9692ca33c86e67822bd5bbd6df12..86cc93215130547dc282955e6cde87d6a23c4b92 100644 (file)
@@ -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;
                }