Re: [U-Boot] [PATCH v7 2/3] cmd: ubifs: Move ubifs_initialized checking into cmd_ubifs_umount()

2018-01-31 Thread Chee, Tien Fong
On Tue, 2018-01-30 at 13:09 +0100, Marek Vasut wrote:
> On 01/30/2018 12:16 PM, tien.fong.c...@intel.com wrote:
> > 
> > From: Tien Fong Chee 
> > 
> > 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 64db5518baa
> > 2ea1a8a0e81cc485d760b850c7052
> > ---
> >  cmd/ubifs.c | 20 
> >  include/ubi_uboot.h |  1 +
> >  2 files changed, 13 insertions(+), 8 deletions(-)
> > 
> > diff --git a/cmd/ubifs.c b/cmd/ubifs.c
> > index 5e9d357..d18e0da 100644
> > --- a/cmd/ubifs.c
> > +++ b/cmd/ubifs.c
> > @@ -51,27 +51,31 @@ 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,
> >     char * const argv[])
> >  {
> > +   int ret;
> > +
> >     if (argc != 1)
> >     return CMD_RET_USAGE;
> >  
> > -   if (ubifs_initialized == 0) {
> > -   printf("No UBIFS volume mounted!\n");
> > -   return -1;
> > -   }
> > -
> > -   cmd_ubifs_umount();
> > +   ret = cmd_ubifs_umount();
> return cmd_ubifs_umount() directly ?
> 
Okay.
> > 
> > -   return 0;
> > +   return ret;
> >  }
> >  
> >  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
> > 
> 
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v7 2/3] cmd: ubifs: Move ubifs_initialized checking into cmd_ubifs_umount()

2018-01-30 Thread Marek Vasut
On 01/30/2018 12:16 PM, tien.fong.c...@intel.com wrote:
> From: Tien Fong Chee 
> 
> 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 
> 64db5518baa2ea1a8a0e81cc485d760b850c7052
> ---
>  cmd/ubifs.c | 20 
>  include/ubi_uboot.h |  1 +
>  2 files changed, 13 insertions(+), 8 deletions(-)
> 
> diff --git a/cmd/ubifs.c b/cmd/ubifs.c
> index 5e9d357..d18e0da 100644
> --- a/cmd/ubifs.c
> +++ b/cmd/ubifs.c
> @@ -51,27 +51,31 @@ 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,
>   char * const argv[])
>  {
> + int ret;
> +
>   if (argc != 1)
>   return CMD_RET_USAGE;
>  
> - if (ubifs_initialized == 0) {
> - printf("No UBIFS volume mounted!\n");
> - return -1;
> - }
> -
> - cmd_ubifs_umount();
> + ret = cmd_ubifs_umount();

return cmd_ubifs_umount() directly ?

> - return 0;
> + return ret;
>  }
>  
>  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
> 


-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v7 2/3] cmd: ubifs: Move ubifs_initialized checking into cmd_ubifs_umount()

2018-01-30 Thread tien . fong . chee
From: Tien Fong Chee 

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 
64db5518baa2ea1a8a0e81cc485d760b850c7052
---
 cmd/ubifs.c | 20 
 include/ubi_uboot.h |  1 +
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/cmd/ubifs.c b/cmd/ubifs.c
index 5e9d357..d18e0da 100644
--- a/cmd/ubifs.c
+++ b/cmd/ubifs.c
@@ -51,27 +51,31 @@ 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,
char * const argv[])
 {
+   int ret;
+
if (argc != 1)
return CMD_RET_USAGE;
 
-   if (ubifs_initialized == 0) {
-   printf("No UBIFS volume mounted!\n");
-   return -1;
-   }
-
-   cmd_ubifs_umount();
+   ret = cmd_ubifs_umount();
 
-   return 0;
+   return ret;
 }
 
 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

___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot