[U-Boot] [PATCH v4 1/6] cmd: ubifs: Move ubifs_initialized checking into cmd_ubifs_umount()

tien.fong.chee at intel.com tien.fong.chee at intel.com
Fri Jul 6 08:25:12 UTC 2018


From: Tien Fong Chee <tien.fong.chee at intel.com>

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 at intel.com>
Reviewed-by: Marek Vasut <marex at denx.de>
---
 cmd/ubifs.c         | 18 +++++++++---------
 include/ubi_uboot.h |  1 +
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/cmd/ubifs.c b/cmd/ubifs.c
index 11bab7a..1710348 100644
--- a/cmd/ubifs.c
+++ b/cmd/ubifs.c
@@ -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,
diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index 80acbcb..827dbfc 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -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
-- 
2.2.0



More information about the U-Boot mailing list