diff mbox

[U-Boot] spl: don't use %#l with CONFIG_USE_TINY_PRINTF

Message ID 1482912736-31304-1-git-send-email-oded.gabbay@gmail.com
State Deferred
Delegated to: Tom Rini
Headers show

Commit Message

Oded Gabbay Dec. 28, 2016, 8:12 a.m. UTC
In the tiny-printf implementation, there is no support for %# and/or %l. This
patch checks if CONFIG_USE_TINY_PRINTF is defined and if so, prints a
different debug statement which doesn't use %#l

Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Cc: Simon Glass <sjg@chromium.org>
---
 common/spl/spl.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Simon Glass Jan. 12, 2017, 5:07 a.m. UTC | #1
On 28 December 2016 at 01:12, Oded Gabbay <oded.gabbay@gmail.com> wrote:
> In the tiny-printf implementation, there is no support for %# and/or %l. This
> patch checks if CONFIG_USE_TINY_PRINTF is defined and if so, prints a
> different debug statement which doesn't use %#l
>
> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  common/spl/spl.c | 5 +++++
>  1 file changed, 5 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
Masahiro Yamada Jan. 17, 2017, 7:30 a.m. UTC | #2
2016-12-28 17:12 GMT+09:00 Oded Gabbay <oded.gabbay@gmail.com>:
> In the tiny-printf implementation, there is no support for %# and/or %l. This
> patch checks if CONFIG_USE_TINY_PRINTF is defined and if so, prints a
> different debug statement which doesn't use %#l
>
> Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
> Cc: Simon Glass <sjg@chromium.org>
> ---
>  common/spl/spl.c | 5 +++++
>  1 file changed, 5 insertions(+)
>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index f7df834..23dfa2d 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -385,9 +385,14 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>                 debug("Unsupported OS image.. Jumping nevertheless..\n");
>         }
>  #if defined(CONFIG_SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE)
> +#ifdef CONFIG_USE_TINY_PRINTF
> +       debug("SPL malloc() used 0x%x bytes (%d KB)\n",
> +               (uint) gd->malloc_ptr, (uint) gd->malloc_ptr / 1024);
> +#else
>         debug("SPL malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
>               gd->malloc_ptr / 1024);
>  #endif
> +#endif
>


Please do not patch around with CONFIG_USE_TINY_PRINTF.

What you need to do is to fix tiny_printf() implementation.
Tom Rini Jan. 19, 2017, 3 a.m. UTC | #3
On Tue, Jan 17, 2017 at 04:30:23PM +0900, Masahiro Yamada wrote:
> 2016-12-28 17:12 GMT+09:00 Oded Gabbay <oded.gabbay@gmail.com>:
> > In the tiny-printf implementation, there is no support for %# and/or %l. This
> > patch checks if CONFIG_USE_TINY_PRINTF is defined and if so, prints a
> > different debug statement which doesn't use %#l
> >
> > Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
> > Cc: Simon Glass <sjg@chromium.org>
> > ---
> >  common/spl/spl.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/common/spl/spl.c b/common/spl/spl.c
> > index f7df834..23dfa2d 100644
> > --- a/common/spl/spl.c
> > +++ b/common/spl/spl.c
> > @@ -385,9 +385,14 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
> >                 debug("Unsupported OS image.. Jumping nevertheless..\n");
> >         }
> >  #if defined(CONFIG_SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE)
> > +#ifdef CONFIG_USE_TINY_PRINTF
> > +       debug("SPL malloc() used 0x%x bytes (%d KB)\n",
> > +               (uint) gd->malloc_ptr, (uint) gd->malloc_ptr / 1024);
> > +#else
> >         debug("SPL malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
> >               gd->malloc_ptr / 1024);
> >  #endif
> > +#endif
> >
> 
> 
> Please do not patch around with CONFIG_USE_TINY_PRINTF.
> 
> What you need to do is to fix tiny_printf() implementation.

That was the first suggestion, but that adds to the tiny printf size.  I
would say we just re-write the code here to always print correctly for
TINY_PRINTF (and further, in this specific case print bytes or KB, not
both, and preferably just bytes).
diff mbox

Patch

diff --git a/common/spl/spl.c b/common/spl/spl.c
index f7df834..23dfa2d 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -385,9 +385,14 @@  void board_init_r(gd_t *dummy1, ulong dummy2)
 		debug("Unsupported OS image.. Jumping nevertheless..\n");
 	}
 #if defined(CONFIG_SYS_MALLOC_F_LEN) && !defined(CONFIG_SYS_SPL_MALLOC_SIZE)
+#ifdef CONFIG_USE_TINY_PRINTF
+	debug("SPL malloc() used 0x%x bytes (%d KB)\n",
+		(uint) gd->malloc_ptr, (uint) gd->malloc_ptr / 1024);
+#else
 	debug("SPL malloc() used %#lx bytes (%ld KB)\n", gd->malloc_ptr,
 	      gd->malloc_ptr / 1024);
 #endif
+#endif
 
 	debug("loaded - jumping to U-Boot...");
 	spl_board_prepare_for_boot();