cmd_mmc.c: check mmc_init() during mmc dev
PATCH 1/1 cmd_mmc.c: check mmc_init() during mmc dev
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.
--- common/cmd_mmc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
common/cmd_mmc.c +5 -1
@@ -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 ) {
Signature · 1 line
1.7.11.4
PATCH 1/1 cmd_mmc.c: check mmc_init() during mmc dev
Quoted 7 lines · Bryan Wu
mmc dev ${devnum} will return 0 as success even if there is no card inserted. Booting script like
tegra-common-post.hwill call mmc dev ${devnum} to check the mmc device status, it always return 0 even ifmmc_init()fails.Check
mmc_init()return value let mmc dev command return failure whenmmc_init()fails.
You probably want to Cc the MMC maintainer.
common/cmd_mmc.c static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 198
Quoted 7 lines
common/cmd_mmc.c +1
-0@@ -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;
The latest u-boot.git master branch already declares ret a couple lines above. Hence, this patch doesn't compile.
common/cmd_mmc.c static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 223
Quoted 4 lines
common/cmd_mmc.c +3
-1-mmc_init (mmc); + ret =mmc_init (mmc); +if (ret) +return ret;
I know that I said off-list to return ret here, but it actually looks like U-Boot commands must not return arbitrary values, but rather must return 0, 1, or CMD_RET_USAGE. The current code prints the following on failure:
Tegra124 (Jetson TK1) # mmc dev 1
MMC: no card present
exit not allowed from main input shell.
I'll send a V2 patch with these fixed.
PATCH 1/1 cmd_mmc.c: check mmc_init() during mmc dev
Quoted 32 lines · Stephen Warren
Quoted 7 lines · Bryan Wu
mmc dev ${devnum} will return 0 as success even if there is no card inserted. Booting script like
tegra-common-post.hwill call mmc dev ${devnum} to check the mmc device status, it always return 0 even ifmmc_init()fails.Check
mmc_init()return value let mmc dev command return failure whenmmc_init()fails.You probably want to Cc the MMC maintainer.
common/cmd_mmc.c static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 198
Quoted 7 lines
common/cmd_mmc.c +1
-0@@ -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;The latest u-boot.git master branch already declares ret a couple lines above. Hence, this patch doesn't compile.
common/cmd_mmc.c static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) · line 223
Quoted 4 lines
common/cmd_mmc.c +3
-1-mmc_init (mmc); + ret =mmc_init (mmc); +if (ret) +return ret;I know that I said off-list to return ret here, but it actually looks like U-Boot commands must not return arbitrary values, but rather must return 0, 1, or
CMD_RET_USAGE. The current code prints the following on failure:
Quoted 5 lines
Tegra124 (Jetson TK1) # mmc dev 1
MMC: no card present
exit not allowed from main input shell.I'll send a V2 patch with these fixed.
Thanks for pushing this. I will update downstream version.
-Bryan