cmd: ubifs: Factor out some checking codes into cmd_ubifs_mount()
authorTien Fong Chee <tien.fong.chee@intel.com>
Fri, 6 Jul 2018 08:26:01 +0000 (16:26 +0800)
committerTom Rini <trini@konsulko.com>
Sat, 29 Sep 2018 00:22:32 +0000 (20:22 -0400)
cmd_ubifs_mount() function would be called directly instead of
involving whole command machinery for mounting ubifs in
generic firmware loader, so some checking codes need to be factored out
into cmd_ubifs_mount() 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>
cmd/ubifs.c
include/ubi_uboot.h

index 171034801b76af0fa4abb024ccfc48eee47bc871..e4000b7ad19dd466940fc7394bc5c45f8f80e54c 100644 (file)
 static int ubifs_initialized;
 static int ubifs_mounted;
 
-static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
-                               char * const argv[])
+int cmd_ubifs_mount(char *vol_name)
 {
-       char *vol_name;
        int ret;
 
-       if (argc != 2)
-               return CMD_RET_USAGE;
-
-       vol_name = argv[1];
        debug("Using volume %s\n", vol_name);
 
        if (ubifs_initialized == 0) {
@@ -42,7 +36,19 @@ static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
 
        ubifs_mounted = 1;
 
-       return 0;
+       return ret;
+}
+static int do_ubifs_mount(cmd_tbl_t *cmdtp, int flag, int argc,
+                               char * const argv[])
+{
+       char *vol_name;
+
+       if (argc != 2)
+               return CMD_RET_USAGE;
+
+       vol_name = argv[1];
+
+       return cmd_ubifs_mount(vol_name);
 }
 
 int ubifs_is_mounted(void)
index 827dbfcd103b333f2dcbcff0454371bab4136679..0770228cd895c6494e6a95b7810b9b8f39008037 100644 (file)
@@ -75,6 +75,7 @@ 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_mount(char *vol_name);
 int cmd_ubifs_umount(void);
 
 #endif