dfu: mmc: use the default MMC device if entity specifies it as -1 45/247845/2
authorMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 17 Nov 2020 09:45:46 +0000 (10:45 +0100)
committerMarek Szyprowski <m.szyprowski@samsung.com>
Tue, 17 Nov 2020 10:55:12 +0000 (11:55 +0100)
Use the default MMC device set in the command line if entity specifies it
as -1. This allows to use the same dfu_alt_info string for different MMC
devices (like embedded eMMC and external SD card if data layout is the
same).

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Change-Id: If076f723f60ab30f7f82c7cc9cffb484a854e29b

drivers/dfu/dfu_mmc.c

index c7c324b..d1af11d 100644 (file)
@@ -323,7 +323,7 @@ void dfu_free_entity_mmc(struct dfu_entity *dfu)
 int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
 {
        const char *entity_type;
-       size_t second_arg;
+       ssize_t second_arg;
        size_t third_arg;
 
        struct mmc *mmc;
@@ -346,7 +346,7 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
         * Base 0 means we'll accept (prefixed with 0x or 0) base 16, 8,
         * with default 10.
         */
-       second_arg = simple_strtoul(argv[1], NULL, 0);
+       second_arg = simple_strtol(argv[1], NULL, 0);
        third_arg = simple_strtoul(argv[2], NULL, 0);
 
        mmc = find_mmc_device(dfu->data.mmc.dev_num);
@@ -415,7 +415,8 @@ int dfu_fill_entity_mmc(struct dfu_entity *dfu, char *devstr, char *s)
 
        /* if it's NOT a raw write */
        if (strcmp(entity_type, "raw")) {
-               dfu->data.mmc.dev = second_arg;
+               dfu->data.mmc.dev = (second_arg != -1) ? second_arg :
+                                                        dfu->data.mmc.dev_num;
                dfu->data.mmc.part = third_arg;
        }