diff mbox series

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

Message ID 1524112377-13724-7-git-send-email-alex.kiernan@gmail.com
State Accepted
Commit 4f1eed7527e256edd10fab85d2651a35e530509f
Delegated to: Tom Rini
Headers show
Series Fix SPL build without CONFIG_SPL_SERIAL_SUPPORT | expand

Commit Message

Alex Kiernan April 19, 2018, 4:32 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>
---

Changes in v2:
- Remove ifdef dance with SPL/TPL now PRINTF exists as its own symbol

 lib/panic.c       |  2 ++
 lib/tiny-printf.c | 12 +++++++-----
 lib/vsprintf.c    |  3 ++-
 3 files changed, 11 insertions(+), 6 deletions(-)

Comments

Tom Rini April 29, 2018, 9:04 p.m. UTC | #1
On Thu, Apr 19, 2018 at 04:32:55AM +0000, 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>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/lib/panic.c b/lib/panic.c
index e2b8b74..0efa134 100644
--- a/lib/panic.c
+++ b/lib/panic.c
@@ -37,9 +37,11 @@  void panic_str(const char *str)
 
 void panic(const char *fmt, ...)
 {
+#if 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..e29377e 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,12 @@  abort:
 	return 0;
 }
 
+#if 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 +344,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..9f0ce8a 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -783,6 +783,7 @@  int sprintf(char *buf, const char *fmt, ...)
 	return i;
 }
 
+#if CONFIG_IS_ENABLED(PRINTF)
 int printf(const char *fmt, ...)
 {
 	va_list args;
@@ -824,7 +825,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)