diff mbox

[U-Boot,3/7] lib/tiny-printf.c: Implement vprintf

Message ID 1449268061-805-4-git-send-email-sjoerd.simons@collabora.co.uk
State Accepted
Delegated to: Simon Glass
Headers show

Commit Message

Sjoerd Simons Dec. 4, 2015, 10:27 p.m. UTC
Implement both printf and vprintf for a bit more flexibility, e.g.
allows the panic() function to work with tiny-printf.

Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
---

 lib/tiny-printf.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

Comments

Simon Glass Dec. 8, 2015, 12:39 a.m. UTC | #1
On 4 December 2015 at 15:27, Sjoerd Simons
<sjoerd.simons@collabora.co.uk> wrote:
> Implement both printf and vprintf for a bit more flexibility, e.g.
> allows the panic() function to work with tiny-printf.
>
> Signed-off-by: Sjoerd Simons <sjoerd.simons@collabora.co.uk>
> ---
>
>  lib/tiny-printf.c | 18 +++++++++++++-----
>  1 file changed, 13 insertions(+), 5 deletions(-)

Acked-by: Simon Glass <sjg@chromium.org>
Tested on firefly:
Tested-by: Simon Glass <sjg@chromium.org>
Simon Glass Dec. 14, 2015, 3:44 a.m. UTC | #2
Applied to u-boot-rockchip, thanks!
diff mbox

Patch

diff --git a/lib/tiny-printf.c b/lib/tiny-printf.c
index 6766a8f..403b134 100644
--- a/lib/tiny-printf.c
+++ b/lib/tiny-printf.c
@@ -40,17 +40,14 @@  static void div_out(unsigned int *num, unsigned int div)
 		out_dgt(dgt);
 }
 
-int printf(const char *fmt, ...)
+int vprintf(const char *fmt, va_list va)
 {
-	va_list va;
 	char ch;
 	char *p;
 	unsigned int num;
 	char buf[12];
 	unsigned int div;
 
-	va_start(va, fmt);
-
 	while ((ch = *(fmt++))) {
 		if (ch != '%') {
 			putc(ch);
@@ -117,6 +114,17 @@  int printf(const char *fmt, ...)
 	}
 
 abort:
-	va_end(va);
 	return 0;
 }
+
+int printf(const char *fmt, ...)
+{
+	va_list va;
+	int ret;
+
+	va_start(va, fmt);
+	ret = vprintf(fmt, va);
+	va_end(va);
+
+	return ret;
+}