From mboxrd@z Thu Jan 1 00:00:00 1970 From: tien.fong.chee at intel.com Date: Mon, 5 Mar 2018 17:43:37 +0800 Subject: [U-Boot] [PATCH v10 3/4] cmd: ubifs: Factor out some checking codes into cmd_ubifs_mount() In-Reply-To: <1520243018-105509-1-git-send-email-tien.fong.chee@intel.com> References: <1520243018-105509-1-git-send-email-tien.fong.chee@intel.com> Message-ID: <1520243018-105509-4-git-send-email-tien.fong.chee@intel.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de From: Tien Fong Chee 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 Reviewed-by: Marek Vasut --- cmd/ubifs.c | 22 ++++++++++++++-------- include/ubi_uboot.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/cmd/ubifs.c b/cmd/ubifs.c index 0d059ca..8339bed 100644 --- a/cmd/ubifs.c +++ b/cmd/ubifs.c @@ -20,16 +20,10 @@ 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) { @@ -43,7 +37,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) diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h index 827dbfc..0770228 100644 --- a/include/ubi_uboot.h +++ b/include/ubi_uboot.h @@ -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 -- 2.2.0