[PATCH 25/27] console: Introduce dvprintf()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



In an effort to consolidate various printf re-implementation,
introduce the most generic form of printf() to be used to implement
other flavours of it.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 common/console_common.c | 18 ----------------
 lib/console.c           | 47 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 46 insertions(+), 19 deletions(-)

diff --git a/common/console_common.c b/common/console_common.c
index 6e098b27d..121f511e6 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -209,24 +209,6 @@ void log_print(unsigned flags)
 	}
 }
 
-int vprintf(const char *fmt, va_list args)
-{
-	int i;
-	char printbuffer[CFG_PBSIZE];
-
-	/*
-	 * For this to work, printbuffer must be larger than
-	 * anything we ever want to print.
-	 */
-	i = vsprintf(printbuffer, fmt, args);
-
-	/* Print the string */
-	puts(printbuffer);
-
-	return i;
-}
-EXPORT_SYMBOL(vprintf);
-
 struct console_device *console_get_by_dev(struct device_d *dev)
 {
 	struct console_device *cdev;
diff --git a/lib/console.c b/lib/console.c
index 57c3578d6..43eeb4cdf 100644
--- a/lib/console.c
+++ b/lib/console.c
@@ -237,4 +237,49 @@ int printf(const char *fmt, ...)
 
 	return i;
 }
-EXPORT_SYMBOL(printf);
\ No newline at end of file
+EXPORT_SYMBOL(printf);
+
+/**
+ * dputs() - Dummy dputs() implementation
+ *
+ * @fd:		File descriptor to print to
+ * @s:		String to print
+ *
+ * This is a dummy dputs() implementation intended to be used in PBL
+ * only. CONSOLE_* code overrides it with more sophisticated version
+ * that actually does correct output routing.
+ */
+__weak int dputs(int fd, const char *s)
+{
+	return console_puts(CONSOLE_STDOUT, s);
+}
+
+/**
+ * dvprintf() - A hybrid between dprintf() and vprintf()
+ *
+ * @fd:		File descriptor to print to
+ * @fmt:	Format string to use
+ * @args:	va_list with the rest of the arguments to be used
+ *
+ * This function is a most generic version of printf-family intended
+ * to be used to implement the rest of the printf-like functions
+ */
+static int dvprintf(int fd, const char *fmt, va_list args)
+{
+	char printbuffer[CFG_PBSIZE];
+
+	/*
+	 * For this to work, printbuffer must be larger than
+	 * anything we ever want to print.
+	 */
+	vsprintf(printbuffer, fmt, args);
+
+	/* Print the string */
+	return dputs(fd, printbuffer);
+}
+
+int vprintf(const char *fmt, va_list args)
+{
+	return dvprintf(STDOUT_FILENO, fmt, args);
+}
+EXPORT_SYMBOL(vprintf);
-- 
2.17.0


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux