* [U-Boot] [PATCH] cmd_mmc.c: check mmc_init() during mmc dev
@ 2014-05-20 0:17 Bryan Wu
2014-05-20 16:55 ` Stephen Warren
0 siblings, 1 reply; 3+ messages in thread
From: Bryan Wu @ 2014-05-20 0:17 UTC (permalink / raw)
To: u-boot
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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] cmd_mmc.c: check mmc_init() during mmc dev
2014-05-20 0:17 [U-Boot] [PATCH] cmd_mmc.c: check mmc_init() during mmc dev Bryan Wu
@ 2014-05-20 16:55 ` Stephen Warren
2014-05-20 18:13 ` Bryan Wu
0 siblings, 1 reply; 3+ messages in thread
From: Stephen Warren @ 2014-05-20 16:55 UTC (permalink / raw)
To: u-boot
On 05/19/2014 06:17 PM, Bryan Wu wrote:
> 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.
You probably want to Cc the MMC maintainer.
> diff --git 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;
The latest u-boot.git master branch already declares ret a couple lines
above. Hence, this patch doesn't compile.
> - 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH] cmd_mmc.c: check mmc_init() during mmc dev
2014-05-20 16:55 ` Stephen Warren
@ 2014-05-20 18:13 ` Bryan Wu
0 siblings, 0 replies; 3+ messages in thread
From: Bryan Wu @ 2014-05-20 18:13 UTC (permalink / raw)
To: u-boot
On Tue, May 20, 2014 at 9:55 AM, Stephen Warren <swarren@wwwdotorg.org> wrote:
> On 05/19/2014 06:17 PM, Bryan Wu wrote:
>> 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.
>
> You probably want to Cc the MMC maintainer.
>
>> diff --git 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;
>
> The latest u-boot.git master branch already declares ret a couple lines
> above. Hence, this patch doesn't compile.
>
>> - 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.
Thanks for pushing this. I will update downstream version.
-Bryan
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2014-05-20 18:13 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-20 0:17 [U-Boot] [PATCH] cmd_mmc.c: check mmc_init() during mmc dev Bryan Wu
2014-05-20 16:55 ` Stephen Warren
2014-05-20 18:13 ` Bryan Wu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox