]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
mmc: mmc_spi: Move argument check to the beginning of mmc_spi_sendcmd()
authorBin Meng <bin.meng@windriver.com>
Tue, 2 Feb 2021 02:48:46 +0000 (10:48 +0800)
committerPeng Fan <peng.fan@nxp.com>
Fri, 19 Feb 2021 07:07:30 +0000 (15:07 +0800)
The argument check should happen before any transfer on the SPI lines.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Jaehoon Chung <jh80.chung@samsung.com>
drivers/mmc/mmc_spi.c

index 23b907328c18e16004ead807f12c42420edfd714..a06862aa48eec6f6f52f0797a4ea24468210518e 100644 (file)
@@ -78,6 +78,9 @@ static int mmc_spi_sendcmd(struct udevice *dev,
        int i, rpos = 0, ret = 0;
        u8 cmdo[7], r;
 
+       if (!resp || !resp_size)
+               return 0;
+
        debug("%s: cmd%d cmdarg=0x%x resp_type=0x%x "
              "resp_size=%d resp_match=%d resp_match_value=0x%x\n",
              __func__, cmdidx, cmdarg, resp_type,
@@ -98,9 +101,6 @@ static int mmc_spi_sendcmd(struct udevice *dev,
        if (ret)
                return ret;
 
-       if (!resp || !resp_size)
-               return 0;
-
        debug("%s: cmd%d", __func__, cmdidx);
 
        if (resp_match) {