Commit a433215b authored by Alessandro Rubini's avatar Alessandro Rubini

diag: allow pp_diag with NULL ppi pointer

Also, add "config" to the list of diag things, to allow tracing config
file errors (used in later commits).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent fe4470bb
......@@ -21,6 +21,7 @@ void __pp_diag(struct pp_instance *ppi, enum pp_diag_things th,
int level, char *fmt, ...)
{
va_list args;
char *name = ppi ? ppi->iface_name : "ppsi";
if (!__PP_DIAG_ALLOW(ppi, th, level))
return;
......@@ -37,7 +38,7 @@ void __pp_diag(struct pp_instance *ppi, enum pp_diag_things th,
extern int DIAG_PUTS(const char *s);
pp_sprintf(buf, "%s-%i-%s: ",
thing_name[th], level, ppi->iface_name);
thing_name[th], level, name);
DIAG_PUTS(buf);
va_start(args, fmt);
pp_vsprintf(buf, fmt, args);
......@@ -46,7 +47,7 @@ void __pp_diag(struct pp_instance *ppi, enum pp_diag_things th,
}
#else
/* Use the normal output channel for diagnostics */
pp_printf("%s-%i-%s: ", thing_name[th], level, ppi->iface_name);
pp_printf("%s-%i-%s: ", thing_name[th], level, name);
va_start(args, fmt);
pp_vprintf(fmt, args);
va_end(args);
......
......@@ -56,6 +56,7 @@ enum pp_diag_things {
pp_dt_servo = 4,
pp_dt_bmc = 3,
pp_dt_ext = 2,
pp_dt_config = 1,
};
/*
* Note: we may use less bits and have more things, without changing
......@@ -70,7 +71,7 @@ extern unsigned long pp_global_flags; /* Supplement ppi-specific ones */
/* So, extract the level */
#define __PP_FLAGS(ppi) (ppi->flags | pp_global_flags)
#define __PP_FLAGS(ppi) ((ppi ? ppi->flags : 0) | pp_global_flags)
#define __PP_DIAG_ALLOW(ppi, th, level) \
((__PP_FLAGS(ppi) >> (4 * (th)) & 0xf) >= level)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment