summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2017-06-19 12:57:10 +0200
committerNico Huber <nico.h@gmx.de>2017-07-13 16:27:55 +0000
commitd152fb95e2b7fda62a85f6c8e4112ba9f353a8d6 (patch)
treecfd2ea28b75cb90db72f488ee237a068d0cb52a4
parent731316a9128c4015bc0facd1743afeb3a080129e (diff)
downloadflashrom-d152fb95e2b7fda62a85f6c8e4112ba9f353a8d6.tar.gz
flashrom-d152fb95e2b7fda62a85f6c8e4112ba9f353a8d6.tar.bz2
flashrom-d152fb95e2b7fda62a85f6c8e4112ba9f353a8d6.zip
Drop redundant `enum msglevel`
Use `enum flashrom_log_level` instead to avoid further confusion. Change-Id: I1895cb8f60da3abf70c9c2953f52414cd2cc10a9 Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/20268 Reviewed-by: Paul Menzel <paulepanter@users.sourceforge.net> Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--cli_classic.c2
-rw-r--r--cli_output.c16
-rw-r--r--flash.h53
-rw-r--r--ichspi.c6
-rw-r--r--libflashrom.c4
-rw-r--r--libflashrom.h2
6 files changed, 38 insertions, 45 deletions
diff --git a/cli_classic.c b/cli_classic.c
index 4c3db4d85..441fc919c 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -203,7 +203,7 @@ int main(int argc, char *argv[])
break;
case 'V':
verbose_screen++;
- if (verbose_screen > MSG_DEBUG2)
+ if (verbose_screen > FLASHROM_MSG_DEBUG2)
verbose_logfile = verbose_screen;
break;
case 'E':
diff --git a/cli_output.c b/cli_output.c
index e69798503..61a9af6ed 100644
--- a/cli_output.c
+++ b/cli_output.c
@@ -25,8 +25,8 @@
#include <errno.h>
#include "flash.h"
-int verbose_screen = MSG_INFO;
-int verbose_logfile = MSG_DEBUG2;
+enum flashrom_log_level verbose_screen = FLASHROM_MSG_INFO;
+enum flashrom_log_level verbose_logfile = FLASHROM_MSG_DEBUG2;
#ifndef STANDALONE
static FILE *logfile = NULL;
@@ -61,17 +61,17 @@ int open_logfile(const char * const filename)
void start_logging(void)
{
- enum msglevel oldverbose_screen = verbose_screen;
+ enum flashrom_log_level oldverbose_screen = verbose_screen;
/* Shut up the console. */
- verbose_screen = MSG_ERROR;
+ verbose_screen = FLASHROM_MSG_ERROR;
print_version();
verbose_screen = oldverbose_screen;
}
#endif /* !STANDALONE */
/* Please note that level is the verbosity, not the importance of the message. */
-int flashrom_print_cb(enum msglevel level, const char *fmt, va_list ap)
+int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap)
{
int ret = 0;
FILE *output_type = stdout;
@@ -79,20 +79,20 @@ int flashrom_print_cb(enum msglevel level, const char *fmt, va_list ap)
va_list logfile_args;
va_copy(logfile_args, ap);
- if (level < MSG_INFO)
+ if (level < FLASHROM_MSG_INFO)
output_type = stderr;
if (level <= verbose_screen) {
ret = vfprintf(output_type, fmt, ap);
/* msg_*spew often happens inside chip accessors in possibly
* time-critical operations. Don't slow them down by flushing. */
- if (level != MSG_SPEW)
+ if (level != FLASHROM_MSG_SPEW)
fflush(output_type);
}
#ifndef STANDALONE
if ((level <= verbose_logfile) && logfile) {
ret = vfprintf(logfile, fmt, logfile_args);
- if (level != MSG_SPEW)
+ if (level != FLASHROM_MSG_SPEW)
fflush(logfile);
}
#endif /* !STANDALONE */
diff --git a/flash.h b/flash.h
index b5eb99ba7..67c7d20c4 100644
--- a/flash.h
+++ b/flash.h
@@ -38,6 +38,7 @@
#undef max
#endif
+#include "libflashrom.h"
#include "layout.h"
#define ERROR_PTR ((void*)-1)
@@ -312,47 +313,39 @@ int do_verify(struct flashctx *, const char *const filename);
void print_chip_support_status(const struct flashchip *chip);
/* cli_output.c */
-extern int verbose_screen;
-extern int verbose_logfile;
+extern enum flashrom_log_level verbose_screen;
+extern enum flashrom_log_level verbose_logfile;
#ifndef STANDALONE
int open_logfile(const char * const filename);
int close_logfile(void);
void start_logging(void);
#endif
-enum msglevel {
- MSG_ERROR = 0,
- MSG_WARN = 1,
- MSG_INFO = 2,
- MSG_DEBUG = 3,
- MSG_DEBUG2 = 4,
- MSG_SPEW = 5,
-};
-int flashrom_print_cb(enum msglevel level, const char *fmt, va_list ap);
+int flashrom_print_cb(enum flashrom_log_level level, const char *fmt, va_list ap);
/* Let gcc and clang check for correct printf-style format strings. */
-int print(enum msglevel level, const char *fmt, ...)
+int print(enum flashrom_log_level level, const char *fmt, ...)
#ifdef __MINGW32__
__attribute__((format(gnu_printf, 2, 3)));
#else
__attribute__((format(printf, 2, 3)));
#endif
-#define msg_gerr(...) print(MSG_ERROR, __VA_ARGS__) /* general errors */
-#define msg_perr(...) print(MSG_ERROR, __VA_ARGS__) /* programmer errors */
-#define msg_cerr(...) print(MSG_ERROR, __VA_ARGS__) /* chip errors */
-#define msg_gwarn(...) print(MSG_WARN, __VA_ARGS__) /* general warnings */
-#define msg_pwarn(...) print(MSG_WARN, __VA_ARGS__) /* programmer warnings */
-#define msg_cwarn(...) print(MSG_WARN, __VA_ARGS__) /* chip warnings */
-#define msg_ginfo(...) print(MSG_INFO, __VA_ARGS__) /* general info */
-#define msg_pinfo(...) print(MSG_INFO, __VA_ARGS__) /* programmer info */
-#define msg_cinfo(...) print(MSG_INFO, __VA_ARGS__) /* chip info */
-#define msg_gdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* general debug */
-#define msg_pdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* programmer debug */
-#define msg_cdbg(...) print(MSG_DEBUG, __VA_ARGS__) /* chip debug */
-#define msg_gdbg2(...) print(MSG_DEBUG2, __VA_ARGS__) /* general debug2 */
-#define msg_pdbg2(...) print(MSG_DEBUG2, __VA_ARGS__) /* programmer debug2 */
-#define msg_cdbg2(...) print(MSG_DEBUG2, __VA_ARGS__) /* chip debug2 */
-#define msg_gspew(...) print(MSG_SPEW, __VA_ARGS__) /* general debug spew */
-#define msg_pspew(...) print(MSG_SPEW, __VA_ARGS__) /* programmer debug spew */
-#define msg_cspew(...) print(MSG_SPEW, __VA_ARGS__) /* chip debug spew */
+#define msg_gerr(...) print(FLASHROM_MSG_ERROR, __VA_ARGS__) /* general errors */
+#define msg_perr(...) print(FLASHROM_MSG_ERROR, __VA_ARGS__) /* programmer errors */
+#define msg_cerr(...) print(FLASHROM_MSG_ERROR, __VA_ARGS__) /* chip errors */
+#define msg_gwarn(...) print(FLASHROM_MSG_WARN, __VA_ARGS__) /* general warnings */
+#define msg_pwarn(...) print(FLASHROM_MSG_WARN, __VA_ARGS__) /* programmer warnings */
+#define msg_cwarn(...) print(FLASHROM_MSG_WARN, __VA_ARGS__) /* chip warnings */
+#define msg_ginfo(...) print(FLASHROM_MSG_INFO, __VA_ARGS__) /* general info */
+#define msg_pinfo(...) print(FLASHROM_MSG_INFO, __VA_ARGS__) /* programmer info */
+#define msg_cinfo(...) print(FLASHROM_MSG_INFO, __VA_ARGS__) /* chip info */
+#define msg_gdbg(...) print(FLASHROM_MSG_DEBUG, __VA_ARGS__) /* general debug */
+#define msg_pdbg(...) print(FLASHROM_MSG_DEBUG, __VA_ARGS__) /* programmer debug */
+#define msg_cdbg(...) print(FLASHROM_MSG_DEBUG, __VA_ARGS__) /* chip debug */
+#define msg_gdbg2(...) print(FLASHROM_MSG_DEBUG2, __VA_ARGS__) /* general debug2 */
+#define msg_pdbg2(...) print(FLASHROM_MSG_DEBUG2, __VA_ARGS__) /* programmer debug2 */
+#define msg_cdbg2(...) print(FLASHROM_MSG_DEBUG2, __VA_ARGS__) /* chip debug2 */
+#define msg_gspew(...) print(FLASHROM_MSG_SPEW, __VA_ARGS__) /* general debug spew */
+#define msg_pspew(...) print(FLASHROM_MSG_SPEW, __VA_ARGS__) /* programmer debug spew */
+#define msg_cspew(...) print(FLASHROM_MSG_SPEW, __VA_ARGS__) /* chip debug spew */
/* layout.c */
int register_include_arg(char *name);
diff --git a/ichspi.c b/ichspi.c
index 218e3b12f..be13f915e 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1738,7 +1738,7 @@ int ich_init_spi(void *spibar, enum ich_chipset ich_gen)
tmp = mmio_readl(ich_spibar + ICH8_REG_VSCC);
msg_pdbg("0xC1: 0x%08x (VSCC)\n", tmp);
msg_pdbg("VSCC: ");
- prettyprint_ich_reg_vscc(tmp, MSG_DEBUG, true);
+ prettyprint_ich_reg_vscc(tmp, FLASHROM_MSG_DEBUG, true);
} else {
if (ich_generation != CHIPSET_BAYTRAIL && desc_valid) {
ichspi_bbar = mmio_readl(ich_spibar + ICH9_REG_BBAR);
@@ -1751,12 +1751,12 @@ int ich_init_spi(void *spibar, enum ich_chipset ich_gen)
tmp = mmio_readl(ich_spibar + ICH9_REG_LVSCC);
msg_pdbg("0xC4: 0x%08x (LVSCC)\n", tmp);
msg_pdbg("LVSCC: ");
- prettyprint_ich_reg_vscc(tmp, MSG_DEBUG, true);
+ prettyprint_ich_reg_vscc(tmp, FLASHROM_MSG_DEBUG, true);
tmp = mmio_readl(ich_spibar + ICH9_REG_UVSCC);
msg_pdbg("0xC8: 0x%08x (UVSCC)\n", tmp);
msg_pdbg("UVSCC: ");
- prettyprint_ich_reg_vscc(tmp, MSG_DEBUG, false);
+ prettyprint_ich_reg_vscc(tmp, FLASHROM_MSG_DEBUG, false);
tmp = mmio_readl(ich_spibar + ICH9_REG_FPB);
msg_pdbg("0xD0: 0x%08x (FPB)\n", tmp);
diff --git a/libflashrom.c b/libflashrom.c
index 962e96fca..6e0f42c9f 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -84,13 +84,13 @@ void flashrom_set_log_callback(flashrom_log_callback *const log_callback)
global_log_callback = log_callback;
}
/** @private */
-int print(const enum msglevel level, const char *const fmt, ...)
+int print(const enum flashrom_log_level level, const char *const fmt, ...)
{
if (global_log_callback) {
int ret;
va_list args;
va_start(args, fmt);
- ret = global_log_callback((enum flashrom_log_level)level, fmt, args);
+ ret = global_log_callback(level, fmt, args);
va_end(args);
return ret;
}
diff --git a/libflashrom.h b/libflashrom.h
index c5d972efe..d3f3dedcf 100644
--- a/libflashrom.h
+++ b/libflashrom.h
@@ -27,7 +27,7 @@
int flashrom_init(int perform_selfcheck);
int flashrom_shutdown(void);
/** @ingroup flashrom-general */
-enum flashrom_log_level { /* This has to match enum msglevel. */
+enum flashrom_log_level {
FLASHROM_MSG_ERROR = 0,
FLASHROM_MSG_WARN = 1,
FLASHROM_MSG_INFO = 2,