diff mbox series

[U-Boot,v1,6/8] spl: Disable printf if not required

Message ID 1524042143-30213-7-git-send-email-alex.kiernan@gmail.com
State Superseded
Delegated to: Tom Rini
Headers show
Series Fix SPL build without CONFIG_SPL_SERIAL_SUPPORT | expand

Commit Message

Alex Kiernan April 18, 2018, 9:02 a.m. UTC
Now we have a guard for printf, disable it in the build if it's not
selected.

Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
---

 lib/panic.c       |  3 +++
 lib/tiny-printf.c | 13 ++++++++-----
 lib/vsprintf.c    |  4 +++-
 3 files changed, 14 insertions(+), 6 deletions(-)

Comments

Jean-Jacques Hiblot April 18, 2018, 9:27 a.m. UTC | #1
On 18/04/2018 11:02, Alex Kiernan wrote:
> Now we have a guard for printf, disable it in the build if it's not
> selected.
>
> Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
> ---
>
>   lib/panic.c       |  3 +++
>   lib/tiny-printf.c | 13 ++++++++-----
>   lib/vsprintf.c    |  4 +++-
>   3 files changed, 14 insertions(+), 6 deletions(-)
>
> diff --git a/lib/panic.c b/lib/panic.c
> index e2b8b74..3ca6421 100644
> --- a/lib/panic.c
> +++ b/lib/panic.c
> @@ -37,9 +37,12 @@ void panic_str(const char *str)
>   
>   void panic(const char *fmt, ...)
>   {
> +#if !(IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)) || \
> +	CONFIG_IS_ENABLED(PRINTF)
Why not use only CONFIG_IS_ENABLED(PRINTF) ?

>   	va_list args;
>   	va_start(args, fmt);
>   	vprintf(fmt, args);
>   	va_end(args);
> +#endif
>   	panic_finish();
>   }
> diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
> index 0b04813..9b97aed 100644
> --- a/lib/tiny-printf.c
> +++ b/lib/tiny-printf.c
> @@ -23,11 +23,6 @@ struct printf_info {
>   	void (*putc)(struct printf_info *info, char ch);
>   };
>   
> -static void putc_normal(struct printf_info *info, char ch)
> -{
> -	putc(ch);
> -}
> -
>   static void out(struct printf_info *info, char c)
>   {
>   	*info->bf++ = c;
> @@ -321,6 +316,13 @@ abort:
>   	return 0;
>   }
>   
> +#if !(IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)) || \
> +	CONFIG_IS_ENABLED(PRINTF)
ditto.
> +static void putc_normal(struct printf_info *info, char ch)
> +{
> +	putc(ch);
> +}
> +
>   int vprintf(const char *fmt, va_list va)
>   {
>   	struct printf_info info;
> @@ -343,6 +345,7 @@ int printf(const char *fmt, ...)
>   
>   	return ret;
>   }
> +#endif
>   
>   static void putc_outstr(struct printf_info *info, char ch)
>   {
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 5f7a5f1..bb0c573 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -783,6 +783,8 @@ int sprintf(char *buf, const char *fmt, ...)
>   	return i;
>   }
>   
> +#if !(IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)) || \
> +	CONFIG_IS_ENABLED(PRINTF)
ditto.

JJ
>   int printf(const char *fmt, ...)
>   {
>   	va_list args;
> @@ -824,7 +826,7 @@ int vprintf(const char *fmt, va_list args)
>   	puts(printbuffer);
>   	return i;
>   }
> -
> +#endif
>   
>   void __assert_fail(const char *assertion, const char *file, unsigned line,
>   		   const char *function)
Alex Kiernan April 18, 2018, 10:29 a.m. UTC | #2
On Wed, Apr 18, 2018 at 10:27 AM, Jean-Jacques Hiblot <jjhiblot@ti.com> wrote:
>
>
> On 18/04/2018 11:02, Alex Kiernan wrote:
>>
>> Now we have a guard for printf, disable it in the build if it's not
>> selected.
>>
>> Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
>> ---
>>
>>   lib/panic.c       |  3 +++
>>   lib/tiny-printf.c | 13 ++++++++-----
>>   lib/vsprintf.c    |  4 +++-
>>   3 files changed, 14 insertions(+), 6 deletions(-)
>>
>> diff --git a/lib/panic.c b/lib/panic.c
>> index e2b8b74..3ca6421 100644
>> --- a/lib/panic.c
>> +++ b/lib/panic.c
>> @@ -37,9 +37,12 @@ void panic_str(const char *str)
>>     void panic(const char *fmt, ...)
>>   {
>> +#if !(IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)) || \
>> +       CONFIG_IS_ENABLED(PRINTF)
>
> Why not use only CONFIG_IS_ENABLED(PRINTF) ?
>

Because I don't have a CONFIG_PRINTF, only
CONFIG_SPL_PRINTF/CONFIG_TPL_PRINTF, so you'd end up with it disabled.

But very happy to add a CONFIG_PRINTF which is default y and would
allow this to be cleaned up.
diff mbox series

Patch

diff --git a/lib/panic.c b/lib/panic.c
index e2b8b74..3ca6421 100644
--- a/lib/panic.c
+++ b/lib/panic.c
@@ -37,9 +37,12 @@  void panic_str(const char *str)
 
 void panic(const char *fmt, ...)
 {
+#if !(IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)) || \
+	CONFIG_IS_ENABLED(PRINTF)
 	va_list args;
 	va_start(args, fmt);
 	vprintf(fmt, args);
 	va_end(args);
+#endif
 	panic_finish();
 }
diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 0b04813..9b97aed 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -23,11 +23,6 @@  struct printf_info {
 	void (*putc)(struct printf_info *info, char ch);
 };
 
-static void putc_normal(struct printf_info *info, char ch)
-{
-	putc(ch);
-}
-
 static void out(struct printf_info *info, char c)
 {
 	*info->bf++ = c;
@@ -321,6 +316,13 @@  abort:
 	return 0;
 }
 
+#if !(IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)) || \
+	CONFIG_IS_ENABLED(PRINTF)
+static void putc_normal(struct printf_info *info, char ch)
+{
+	putc(ch);
+}
+
 int vprintf(const char *fmt, va_list va)
 {
 	struct printf_info info;
@@ -343,6 +345,7 @@  int printf(const char *fmt, ...)
 
 	return ret;
 }
+#endif
 
 static void putc_outstr(struct printf_info *info, char ch)
 {
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 5f7a5f1..bb0c573 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -783,6 +783,8 @@  int sprintf(char *buf, const char *fmt, ...)
 	return i;
 }
 
+#if !(IS_ENABLED(CONFIG_SPL_BUILD) || IS_ENABLED(CONFIG_TPL_BUILD)) || \
+	CONFIG_IS_ENABLED(PRINTF)
 int printf(const char *fmt, ...)
 {
 	va_list args;
@@ -824,7 +826,7 @@  int vprintf(const char *fmt, va_list args)
 	puts(printbuffer);
 	return i;
 }
-
+#endif
 
 void __assert_fail(const char *assertion, const char *file, unsigned line,
 		   const char *function)