diff --git a/src/console/vsprintf.c b/src/console/vsprintf.c index 435401b7ef..321ce81490 100644 --- a/src/console/vsprintf.c +++ b/src/console/vsprintf.c @@ -20,32 +20,32 @@ */ #include -#include #include #include -DECLARE_SPIN_LOCK(vsprintf_lock) - -static char *str_buf; - -static void str_tx_byte(unsigned char byte) +struct vsprintf_context { - *str_buf = byte; - str_buf++; + char *str_buf; +}; + +static void str_tx_byte(unsigned char byte, void *data) +{ + struct vsprintf_context *ctx = data; + *ctx->str_buf = byte; + ctx->str_buf++; } static int vsprintf(char *buf, const char *fmt, va_list args) { int i; + struct vsprintf_context ctx; DISABLE_TRACE; - spin_lock(&vsprintf_lock); - str_buf = buf; - i = vtxprintf(str_tx_byte, fmt, args); - *str_buf = '\0'; + ctx.str_buf = buf; + i = vtxdprintf(str_tx_byte, fmt, args, &ctx); + *ctx.str_buf = '\0'; - spin_unlock(&vsprintf_lock); ENABLE_TRACE; return i;