cmd: ubifs: Move ubifs_initialized checking into cmd_ubifs_umount()
authorTien Fong Chee <tien.fong.chee@intel.com>
Fri, 6 Jul 2018 08:25:12 +0000 (16:25 +0800)
committerTom Rini <trini@konsulko.com>
Sat, 29 Sep 2018 00:21:47 +0000 (20:21 -0400)
cmd_ubifs_umount() function would be called directly instead of involving
whole command machinery in generic firmware loader, so checking on
ubifs_initialized status need to be done in cmd_ubifs_umount() without
breaking original functionality design.

Signed-off-by: Tien Fong Chee <tien.fong.chee@intel.com>
Reviewed-by: Marek Vasut <marex@denx.de>
Reviewed-by: Heiko Schocher <hs@denx.de>
[trini: Fix conflicting type error in cmd/ubi.c]
Signed-off-by: Tom Rini <trini@konsulko.com>
cmd/ubi.c
cmd/ubifs.c
include/ubi_uboot.h

index 913f0f71fd99b83dab958bc5620e62a1af3c6487..0fa7553072a3b591cd3b0203bcc1c6a4ba40ee15 100644 (file)
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -47,8 +47,7 @@ struct selected_dev {
 static struct selected_dev ubi_dev;
 
 #ifdef CONFIG_CMD_UBIFS
-int ubifs_is_mounted(void);
-void cmd_ubifs_umount(void);
+#include <ubifs_uboot.h>
 #endif
 
 static void display_volume_info(struct ubi_device *ubi)
index 11bab7a1a1f67546bfc357faef8d315a4309795d..171034801b76af0fa4abb024ccfc48eee47bc871 100644 (file)
@@ -50,11 +50,18 @@ int ubifs_is_mounted(void)
        return ubifs_mounted;
 }
 
-void cmd_ubifs_umount(void)
+int cmd_ubifs_umount(void)
 {
+       if (ubifs_initialized == 0) {
+               printf("No UBIFS volume mounted!\n");
+               return -1;
+       }
+
        uboot_ubifs_umount();
        ubifs_mounted = 0;
        ubifs_initialized = 0;
+
+       return 0;
 }
 
 static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc,
@@ -63,14 +70,7 @@ static int do_ubifs_umount(cmd_tbl_t *cmdtp, int flag, int argc,
        if (argc != 1)
                return CMD_RET_USAGE;
 
-       if (ubifs_initialized == 0) {
-               printf("No UBIFS volume mounted!\n");
-               return -1;
-       }
-
-       cmd_ubifs_umount();
-
-       return 0;
+       return cmd_ubifs_umount();
 }
 
 static int do_ubifs_ls(cmd_tbl_t *cmdtp, int flag, int argc,
index 80acbcb148683d1a6e1ae44b59bd44e66cd93ef6..827dbfcd103b333f2dcbcff0454371bab4136679 100644 (file)
@@ -75,5 +75,6 @@ extern int ubi_volume_write(char *volume, void *buf, size_t size);
 extern int ubi_volume_read(char *volume, char *buf, size_t size);
 
 extern struct ubi_device *ubi_devices[];
+int cmd_ubifs_umount(void);
 
 #endif