[PATCH 1/1] cmd: mmc: fix help and parameter verification with MMC_SPEED_MODE_SET not set
Quentin Schulz
quentin.schulz at cherry.de
Thu Jun 25 16:34:49 CEST 2026
Hi Alexander,
On 6/1/26 12:13 PM, Alexander Stein wrote:
> From: Markus Niebel <Markus.Niebel at ew.tq-group.com>
>
> Currently help and parameter scanning does not check whether the feature
> is enabled or not. This leads to wrong expectations based on help output
> and no clear sign why the mmc dev and mmc rescan do not enforce the
> supplied mode.
>
> Fixes: 19f7a34a4642 ("mmc: Add support for enumerating MMC card in a given mode using mmc command")
>
> Signed-off-by: Markus Niebel <Markus.Niebel at ew.tq-group.com>
> Signed-off-by: Alexander Stein <alexander.stein at ew.tq-group.com>
> ---
> cmd/mmc.c | 21 ++++++++++++++-------
> 1 file changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/cmd/mmc.c b/cmd/mmc.c
> index 81b1ca4ad84..54c799891e1 100644
> --- a/cmd/mmc.c
> +++ b/cmd/mmc.c
> @@ -519,7 +519,7 @@ static int do_mmc_rescan(struct cmd_tbl *cmdtp, int flag,
>
> if (argc == 1) {
> mmc = init_mmc_device(curr_device, true);
> - } else if (argc == 2) {
> + } else if ((argc == 2) && (CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET))) {
> enum bus_mode speed_mode;
>
> speed_mode = (int)dectoul(argv[1], NULL);
> @@ -564,11 +564,13 @@ static int do_mmc_dev(struct cmd_tbl *cmdtp, int flag,
>
> switch (argc) {
> case 4:
> - speed_mode = (int)dectoul(argv[3], &endp);
> - if (*endp) {
> - printf("Invalid speed mode index '%s', did you specify a mode name?\n",
> - argv[3]);
> - return CMD_RET_USAGE;
> + if (CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET)) {
> + speed_mode = (int)dectoul(argv[3], &endp);
> + if (*endp) {
> + printf("Invalid speed mode index '%s', did you specify a mode name?\n",
> + argv[3]);
> + return CMD_RET_USAGE;
> + }
This results in a different behavior for
mmc rescan mode
and
mmc dev dev part mode mode
when MMC_SPEED_MODE_SET is disabled as the former will fail and return
usage, while the latter will silently ignore it. We need consistency I
believe. Which one to pick, I don't know.
> }
>
> fallthrough;
> @@ -1312,12 +1314,17 @@ U_BOOT_CMD(
> #endif
> "mmc erase blk# cnt\n"
> "mmc erase partname\n"
> +#if CONFIG_IS_ENABLED(MMC_SPEED_MODE_SET)
> "mmc rescan [mode]\n"
> - "mmc part - lists available partition on current mmc device\n"
> "mmc dev [dev] [part] [mode] - show or set current mmc device [partition] and set mode\n"
> " - the required speed mode is passed as the index from the following list\n"
> " [MMC_LEGACY, MMC_HS, SD_HS, MMC_HS_52, MMC_DDR_52, UHS_SDR12, UHS_SDR25,\n"
> " UHS_SDR50, UHS_DDR50, UHS_SDR104, MMC_HS_200, MMC_HS_400, MMC_HS_400_ES]\n"
> +#else
> + "mmc rescan\n"
> + "mmc dev [dev] [part] - show or set current mmc device [partition]\n"
> +#endif
> + "mmc part - lists available partition on current mmc device\n"
> "mmc list - lists available devices\n"
> "mmc wp [PART] - power on write protect boot partitions\n"
> " arguments:\n"
Just so no one else has to check: the docs already mention this
limitation so they don't need an update.
Cheers,
Quentin
More information about the U-Boot
mailing list