Rename do_printk() to printk()

The indirection seems unnecessary. The macros throw features like
`-Wmisleading-indentation` off, though.

Default build for QEMU/Q35 is unchanged.

Change-Id: Ie4eab935a367b5ad6b38225c4973d41d9f70ef10
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/51887
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Nico Huber 2021-03-27 20:03:02 +01:00 committed by Patrick Georgi
parent 879ccaa7c5
commit 7cc14ac25d
7 changed files with 32 additions and 36 deletions

View File

@ -69,7 +69,7 @@ static void wrap_putchar_cbmemc(unsigned char byte, void *data)
__cbmemc_tx_byte(byte); __cbmemc_tx_byte(byte);
} }
int do_vprintk(int msg_level, const char *fmt, va_list args) int vprintk(int msg_level, const char *fmt, va_list args)
{ {
int i, log_this; int i, log_this;
@ -98,13 +98,13 @@ int do_vprintk(int msg_level, const char *fmt, va_list args)
return i; return i;
} }
int do_printk(int msg_level, const char *fmt, ...) int printk(int msg_level, const char *fmt, ...)
{ {
va_list args; va_list args;
int i; int i;
va_start(args, fmt); va_start(args, fmt);
i = do_vprintk(msg_level, fmt, args); i = vprintk(msg_level, fmt, args);
va_end(args); va_end(args);
return i; return i;

View File

@ -710,14 +710,14 @@ static void resource_tree(const struct device *root, int debug_level, int depth)
indent[i] = ' '; indent[i] = ' ';
indent[i] = '\0'; indent[i] = '\0';
do_printk(BIOS_DEBUG, "%s%s", indent, dev_path(root)); printk(BIOS_DEBUG, "%s%s", indent, dev_path(root));
if (root->link_list && root->link_list->children) if (root->link_list && root->link_list->children)
do_printk(BIOS_DEBUG, " child on link 0 %s", printk(BIOS_DEBUG, " child on link 0 %s",
dev_path(root->link_list->children)); dev_path(root->link_list->children));
do_printk(BIOS_DEBUG, "\n"); printk(BIOS_DEBUG, "\n");
for (res = root->resource_list; res; res = res->next) { for (res = root->resource_list; res; res = res->next) {
do_printk(debug_level, "%s%s resource base %llx size %llx " printk(debug_level, "%s%s resource base %llx size %llx "
"align %d gran %d limit %llx flags %lx index %lx\n", "align %d gran %d limit %llx flags %lx index %lx\n",
indent, dev_path(root), res->base, res->size, indent, dev_path(root), res->base, res->size,
res->align, res->gran, res->limit, res->flags, res->align, res->gran, res->limit, res->flags,
@ -735,12 +735,12 @@ void print_resource_tree(const struct device *root, int debug_level,
{ {
/* Bail if root is null. */ /* Bail if root is null. */
if (!root) { if (!root) {
do_printk(debug_level, "%s passed NULL for root!\n", __func__); printk(debug_level, "%s passed NULL for root!\n", __func__);
return; return;
} }
/* Bail if not printing to screen. */ /* Bail if not printing to screen. */
if (!do_printk(debug_level, "Show resources in subtree (%s)...%s\n", if (!printk(debug_level, "Show resources in subtree (%s)...%s\n",
dev_path(root), msg)) dev_path(root), msg))
return; return;
@ -758,7 +758,7 @@ void show_devs_tree(const struct device *dev, int debug_level, int depth)
depth_str[i] = ' '; depth_str[i] = ' ';
depth_str[i] = '\0'; depth_str[i] = '\0';
do_printk(debug_level, "%s%s: enabled %d\n", printk(debug_level, "%s%s: enabled %d\n",
depth_str, dev_path(dev), dev->enabled); depth_str, dev_path(dev), dev->enabled);
for (link = dev->link_list; link; link = link->next) { for (link = dev->link_list; link; link = link->next) {
@ -771,7 +771,7 @@ void show_devs_tree(const struct device *dev, int debug_level, int depth)
void show_all_devs_tree(int debug_level, const char *msg) void show_all_devs_tree(int debug_level, const char *msg)
{ {
/* Bail if not printing to screen. */ /* Bail if not printing to screen. */
if (!do_printk(debug_level, "Show all devs in tree form... %s\n", msg)) if (!printk(debug_level, "Show all devs in tree form... %s\n", msg))
return; return;
show_devs_tree(all_devices, debug_level, 0); show_devs_tree(all_devices, debug_level, 0);
} }
@ -779,10 +779,10 @@ void show_all_devs_tree(int debug_level, const char *msg)
void show_devs_subtree(struct device *root, int debug_level, const char *msg) void show_devs_subtree(struct device *root, int debug_level, const char *msg)
{ {
/* Bail if not printing to screen. */ /* Bail if not printing to screen. */
if (!do_printk(debug_level, "Show all devs in subtree %s... %s\n", if (!printk(debug_level, "Show all devs in subtree %s... %s\n",
dev_path(root), msg)) dev_path(root), msg))
return; return;
do_printk(debug_level, "%s\n", msg); printk(debug_level, "%s\n", msg);
show_devs_tree(root, debug_level, 0); show_devs_tree(root, debug_level, 0);
} }
@ -791,10 +791,10 @@ void show_all_devs(int debug_level, const char *msg)
struct device *dev; struct device *dev;
/* Bail if not printing to screen. */ /* Bail if not printing to screen. */
if (!do_printk(debug_level, "Show all devs... %s\n", msg)) if (!printk(debug_level, "Show all devs... %s\n", msg))
return; return;
for (dev = all_devices; dev; dev = dev->next) { for (dev = all_devices; dev; dev = dev->next) {
do_printk(debug_level, "%s: enabled %d\n", printk(debug_level, "%s: enabled %d\n",
dev_path(dev), dev->enabled); dev_path(dev), dev->enabled);
} }
} }
@ -808,7 +808,7 @@ void show_one_resource(int debug_level, struct device *dev,
end = resource_end(resource); end = resource_end(resource);
buf[0] = '\0'; buf[0] = '\0';
do_printk(debug_level, "%s %02lx <- [0x%010llx - 0x%010llx] " printk(debug_level, "%s %02lx <- [0x%010llx - 0x%010llx] "
"size 0x%08llx gran 0x%02x %s%s%s\n", dev_path(dev), "size 0x%08llx gran 0x%02x %s%s%s\n", dev_path(dev),
resource->index, base, end, resource->size, resource->gran, resource->index, base, end, resource->size, resource->gran,
buf, resource_type(resource), comment); buf, resource_type(resource), comment);
@ -818,12 +818,12 @@ void show_all_devs_resources(int debug_level, const char *msg)
{ {
struct device *dev; struct device *dev;
if (!do_printk(debug_level, "Show all devs with resources... %s\n", msg)) if (!printk(debug_level, "Show all devs with resources... %s\n", msg))
return; return;
for (dev = all_devices; dev; dev = dev->next) { for (dev = all_devices; dev; dev = dev->next) {
struct resource *res; struct resource *res;
do_printk(debug_level, "%s: enabled %d\n", printk(debug_level, "%s: enabled %d\n",
dev_path(dev), dev->enabled); dev_path(dev), dev->enabled);
for (res = dev->resource_list; res; res = res->next) for (res = dev->resource_list; res; res = res->next)
show_one_resource(debug_level, dev, res, ""); show_one_resource(debug_level, dev, res, "");

View File

@ -50,6 +50,10 @@ static inline int get_console_loglevel(void)
#if __CONSOLE_ENABLE__ #if __CONSOLE_ENABLE__
asmlinkage void console_init(void); asmlinkage void console_init(void);
int console_log_level(int msg_level); int console_log_level(int msg_level);
int printk(int msg_level, const char *fmt, ...) __attribute__((format(printf, 2, 3)));
int vprintk(int msg_level, const char *fmt, va_list args);
void do_putchar(unsigned char byte); void do_putchar(unsigned char byte);
/* Return number of microseconds elapsed from start of stage or the previous /* Return number of microseconds elapsed from start of stage or the previous
@ -57,25 +61,17 @@ void do_putchar(unsigned char byte);
long console_time_get_and_reset(void); long console_time_get_and_reset(void);
void console_time_report(void); void console_time_report(void);
#define printk(LEVEL, fmt, args...) do_printk(LEVEL, fmt, ##args)
#define vprintk(LEVEL, fmt, args) do_vprintk(LEVEL, fmt, args)
enum { CONSOLE_LOG_NONE = 0, CONSOLE_LOG_FAST, CONSOLE_LOG_ALL }; enum { CONSOLE_LOG_NONE = 0, CONSOLE_LOG_FAST, CONSOLE_LOG_ALL };
#else #else
static inline void console_init(void) {} static inline void console_init(void) {}
static inline int console_log_level(int msg_level) { return 0; } static inline int console_log_level(int msg_level) { return 0; }
static inline void static inline int
__attribute__((format(printf, 2, 3))) __attribute__((format(printf, 2, 3)))
printk(int LEVEL, const char *fmt, ...) {} printk(int LEVEL, const char *fmt, ...) { return 0; }
static inline void vprintk(int LEVEL, const char *fmt, va_list args) {} static inline int vprintk(int LEVEL, const char *fmt, va_list args) { return 0; }
static inline void do_putchar(unsigned char byte) {} static inline void do_putchar(unsigned char byte) {}
static inline long console_time_get_and_reset(void) { return 0; } static inline long console_time_get_and_reset(void) { return 0; }
static inline void console_time_report(void) {} static inline void console_time_report(void) {}
#endif #endif
int do_printk(int msg_level, const char *fmt, ...)
__attribute__((format(printf, 2, 3)));
int do_vprintk(int msg_level, const char *fmt, va_list args);
#endif /* CONSOLE_CONSOLE_H_ */ #endif /* CONSOLE_CONSOLE_H_ */

View File

@ -11,19 +11,19 @@ void console_hw_init(void)
__cbmemc_init(); __cbmemc_init();
} }
int do_printk(int msg_level, const char *fmt, ...) int printk(int msg_level, const char *fmt, ...)
{ {
va_list args; va_list args;
int i; int i;
va_start(args, fmt); va_start(args, fmt);
i = do_vprintk(msg_level, fmt, args); i = vprintk(msg_level, fmt, args);
va_end(args); va_end(args);
return i; return i;
} }
int do_vprintk(int msg_level, const char *fmt, va_list args) int vprintk(int msg_level, const char *fmt, va_list args)
{ {
int i, cnt, log_this; int i, cnt, log_this;
char buf[256]; char buf[256];

View File

@ -4,12 +4,12 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdio.h> #include <stdio.h>
int do_printk(int msg_level, const char *fmt, ...) int printk(int msg_level, const char *fmt, ...)
{ {
return 0; return 0;
} }
int do_vprintk(int msg_level, const char *fmt, va_list args) int vprintk(int msg_level, const char *fmt, va_list args)
{ {
return 0; return 0;
} }

View File

@ -29,7 +29,7 @@ uio_usbdebug_intel.c - Port enable code for Intel chipsets.
linux/uio_ehci_pci.c - Kernel part of the uio interface. linux/uio_ehci_pci.c - Kernel part of the uio interface.
console/printk.c - A do_printk() implementation so you can see debug console/printk.c - A printk() implementation so you can see debug
output with CONFIG_DEBUG_USBDEBUG enabled. output with CONFIG_DEBUG_USBDEBUG enabled.
device/*.c lib/*.c - Some stubs for (hopefully) unneeded functions for device/*.c lib/*.c - Some stubs for (hopefully) unneeded functions for

View File

@ -4,7 +4,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <console/console.h> #include <console/console.h>
int do_printk(int msg_level, const char *const fmt, ...) int printk(int msg_level, const char *const fmt, ...)
{ {
va_list args; va_list args;
int i; int i;