[PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper

Jason Liu jason.hui.liu at nxp.com
Tue Aug 30 03:50:43 CEST 2022



> -----Original Message-----
> From: Ovidiu Panait <ovpanait at gmail.com>
> Sent: 2022年8月30日 1:02
> To: u-boot at lists.denx.de
> Cc: Ovidiu Panait <ovpanait at gmail.com>; Simon Glass <sjg at chromium.org>;
> Andy Shevchenko <andriy.shevchenko at linux.intel.com>; Dzmitry Sankouski
> <dsankouski at gmail.com>; Heinrich Schuchardt <xypron.glpk at gmx.de>; Jason
> Liu <jason.hui.liu at nxp.com>
> Subject: [PATCH v2 3/4] cmd: bdinfo: introduce bdinfo_print_size() helper
> 
> Add bdinfo_print_size() helper to display size variables (such as cache
> sizes) in bdinfo format. The size is printed as "xxx Bytes", "xxx KiB",
"xxx MiB",
> "xxx GiB", etc as needed;
> 
> Reviewed-by: Simon Glass <sjg at chromium.org>
> Signed-off-by: Ovidiu Panait <ovpanait at gmail.com>
> ---
> 
> Changes in v2:
> Added "Reviewed-by" tag from Simon.
> 
>  cmd/bdinfo.c   |  7 +++++++
>  include/init.h | 13 +++++++++++++
>  2 files changed, 20 insertions(+)
> 
The patch looks good to me.

Reviewed-by: Jason Liu <jason.hui.liu at nxp.com>

> diff --git a/cmd/bdinfo.c b/cmd/bdinfo.c index 37cd8a57eb..9e23c4dd8f
> 100644
> --- a/cmd/bdinfo.c
> +++ b/cmd/bdinfo.c
> @@ -16,9 +16,16 @@
>  #include <vsprintf.h>
>  #include <asm/cache.h>
>  #include <asm/global_data.h>
> +#include <display_options.h>
> 
>  DECLARE_GLOBAL_DATA_PTR;
> 
> +void bdinfo_print_size(const char *name, uint64_t size) {
> +	printf("%-12s= ", name);
> +	print_size(size, "\n");
> +}
> +
>  void bdinfo_print_num_l(const char *name, ulong value)  {
>  	printf("%-12s= 0x%0*lx\n", name, 2 * (int)sizeof(value), value);
diff --git
> a/include/init.h b/include/init.h index 7b8f62c121..02bb4ce13e 100644
> --- a/include/init.h
> +++ b/include/init.h
> @@ -343,6 +343,19 @@ void bdinfo_print_num_ll(const char *name,
> unsigned long long value);
>  /* Print a clock speed in MHz */
>  void bdinfo_print_mhz(const char *name, unsigned long hz);
> 
> +/**
> + * bdinfo_print_size - print size variables in bdinfo format
> + * @name:	string to print before the size
> + * @size:	size to print
> + *
> + * Helper function for displaying size variables as properly formatted
> +bdinfo
> + * entries. The size is printed as "xxx Bytes", "xxx KiB", "xxx MiB",
> + * "xxx GiB", etc. as needed;
> + *
> + * For use in arch_print_bdinfo().
> + */
> +void bdinfo_print_size(const char *name, uint64_t size);
> +
>  /* Show arch-specific information for the 'bd' command */  void
> arch_print_bdinfo(void);
> 
> --
> 2.25.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 9583 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20220830/c6f9e337/attachment.bin>


More information about the U-Boot mailing list