[U-Boot] [PATCH] cmd_mmc.c: check mmc_init() during mmc dev

Bryan Wu
2014-05-20T00:17:40Z

mmc dev ${devnum} will return 0 as success even if there is no card
inserted. Booting script like tegra-common-post.h will call mmc dev
${devnum} to check the mmc device status, it always return 0 even if
mmc_init() fails.

Check mmc_init() return value let mmc dev command return failure
when mmc_init() fails.

Signed-off-by: Bryan Wu <pengw@nvidia.com>
---
common/cmd_mmc.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/common/cmd_mmc.c b/common/cmd_mmc.c
index c1916c9..56dcf48 100644
--- a/common/cmd_mmc.c
+++ b/common/cmd_mmc.c
@@ -195,6 +195,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
} else if (strcmp(argv[1], "dev") == 0) {
int dev, part = -1;
struct mmc *mmc;
+ int ret;

if (argc == 2)
dev = curr_device;
@@ -217,7 +218,10 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
return 1;
}

- mmc_init(mmc);
+ ret = mmc_init(mmc);
+ if (ret)
+ return ret;
+
if (part != -1) {
int ret;
if (mmc->part_config == MMCPART_NOAVAILABLE) {
--
1.7.11.4