common: command: Rework the 'cmd is repeatable' logic
[oweals/u-boot.git] / cmd / mmc.c
index c2ee2d9c0af1d9e77d4339621a2173411e92d07a..8bc3648193cf33a26d0376867cad5dfc3028bd22 100644 (file)
--- a/cmd/mmc.c
+++ b/cmd/mmc.c
@@ -101,10 +101,19 @@ static struct mmc *init_mmc_device(int dev, bool force_init)
                return NULL;
        }
 
+       if (!mmc_getcd(mmc))
+               force_init = true;
+
        if (force_init)
                mmc->has_init = 0;
        if (mmc_init(mmc))
                return NULL;
+
+#ifdef CONFIG_BLOCK_CACHE
+       struct blk_desc *bd = mmc_get_blk_desc(mmc);
+       blkcache_invalidate(bd->if_type, bd->devnum);
+#endif
+
        return mmc;
 }
 static int do_mmcinfo(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
@@ -247,7 +256,7 @@ static int do_mmcrpmb(cmd_tbl_t *cmdtp, int flag,
 
        if (cp == NULL || argc > cp->maxargs)
                return CMD_RET_USAGE;
-       if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
+       if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp))
                return CMD_RET_SUCCESS;
 
        mmc = init_mmc_device(curr_device, false);
@@ -907,7 +916,7 @@ static int do_mmcops(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 
        if (cp == NULL || argc > cp->maxargs)
                return CMD_RET_USAGE;
-       if (flag == CMD_FLAG_REPEAT && !cp->repeatable)
+       if (flag == CMD_FLAG_REPEAT && !cmd_is_repeatable(cp))
                return CMD_RET_SUCCESS;
 
        if (curr_device < 0) {
@@ -935,6 +944,7 @@ U_BOOT_CMD(
        "mmc part - lists available partition on current mmc device\n"
        "mmc dev [dev] [part] - show or set current mmc device [partition]\n"
        "mmc list - lists available devices\n"
+#if CONFIG_IS_ENABLED(MMC_HW_PARTITIONING)
        "mmc hwpartition [args...] - does hardware partitioning\n"
        "  arguments (sizes in 512-byte blocks):\n"
        "    [user [enh start cnt] [wrrel {on|off}]] - sets user data area attributes\n"
@@ -942,6 +952,7 @@ U_BOOT_CMD(
        "    [check|set|complete] - mode, complete set partitioning completed\n"
        "  WARNING: Partitioning is a write-once setting once it is set to complete.\n"
        "  Power cycling is required to initialize partitions after set to complete.\n"
+#endif
 #ifdef CONFIG_SUPPORT_EMMC_BOOT
        "mmc bootbus dev boot_bus_width reset_boot_bus_width boot_mode\n"
        " - Set the BOOT_BUS_WIDTH field of the specified device\n"