[PATCH 22/27] console: Convert pr_print into a single line #define

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

 



If we change dev_printf() to not print device related info at the
start if NULL is passed as device pointer, we can easliy use that
function to do what pr_print does. With this change we can convert
pr_print to be a simple macro that expands into a dev_printf() and
drop a bit of exctra code.

Signed-off-by: Andrey Smirnov <andrew.smirnov@xxxxxxxxx>
---
 common/console_common.c | 28 +++++-----------------------
 include/printk.h        |  3 +--
 2 files changed, 6 insertions(+), 25 deletions(-)

diff --git a/common/console_common.c b/common/console_common.c
index f440a9448..296b181d9 100644
--- a/common/console_common.c
+++ b/common/console_common.c
@@ -124,26 +124,6 @@ static void print_colored_log_level(const int level)
 	pr_puts(level, colored_log_level[level]);
 }
 
-int pr_print(int level, const char *fmt, ...)
-{
-	va_list args;
-	int i;
-	char printbuffer[CFG_PBSIZE];
-
-	if (!IS_ENABLED(CONFIG_LOGBUF) && level > barebox_loglevel)
-		return 0;
-
-	print_colored_log_level(level);
-
-	va_start(args, fmt);
-	i = vsprintf(printbuffer, fmt, args);
-	va_end(args);
-
-	pr_puts(level, printbuffer);
-
-	return i;
-}
-
 int dev_printf(int level, const struct device_d *dev, const char *format, ...)
 {
 	va_list args;
@@ -155,10 +135,12 @@ int dev_printf(int level, const struct device_d *dev, const char *format, ...)
 
 	print_colored_log_level(level);
 
-	if (dev->driver && dev->driver->name)
-		ret += sprintf(printbuffer, "%s ", dev->driver->name);
+	if (dev) {
+		if (dev->driver && dev->driver->name)
+			ret += sprintf(printbuffer, "%s ", dev->driver->name);
 
-	ret += sprintf(printbuffer + ret, "%s: ", dev_name(dev));
+		ret += sprintf(printbuffer + ret, "%s: ", dev_name(dev));
+	}
 
 	va_start(args, format);
 
diff --git a/include/printk.h b/include/printk.h
index 9f1831fbe..2bf0cb25b 100644
--- a/include/printk.h
+++ b/include/printk.h
@@ -35,8 +35,7 @@ static inline int dev_printf(int level, const struct device_d *dev, const char *
 #endif
 
 #if (!defined(__PBL__) && !defined(CONFIG_CONSOLE_NONE))
-int pr_print(int level, const char *format, ...)
-	__attribute__ ((format(__printf__, 2, 3)));
+#define pr_print(level, format, arg...)	dev_printf(level, NULL, format, ## arg)
 #elif defined(__PBL__) && defined(CONFIG_PBL_CONSOLE)
 #define pr_print(level, format, arg...)	printf(format, ## arg)
 #else
-- 
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