From 8391ad2721078bee91476dc5d7b9104623f48bb5 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Mon, 31 Jan 2022 16:36:24 +0800 Subject: [PATCH] syslog: Change g_syslog_default_sem to static function variable Signed-off-by: Xiang Xiao --- drivers/syslog/syslog_channel.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/drivers/syslog/syslog_channel.c b/drivers/syslog/syslog_channel.c index 833c4fb358..1b26eef7f6 100644 --- a/drivers/syslog/syslog_channel.c +++ b/drivers/syslog/syslog_channel.c @@ -115,10 +115,6 @@ static struct syslog_channel_s g_rtt_channel = #endif #if defined(CONFIG_SYSLOG_DEFAULT) -# if defined(CONFIG_ARCH_LOWPUTC) -static sem_t g_syslog_default_sem = SEM_INITIALIZER(1); -# endif - static const struct syslog_channel_ops_s g_default_channel_ops = { syslog_default_putc, @@ -184,15 +180,16 @@ static ssize_t syslog_default_write(FAR struct syslog_channel_s *channel, FAR const char *buffer, size_t buflen) { #if defined(CONFIG_ARCH_LOWPUTC) + static sem_t sem = SEM_INITIALIZER(1); size_t nwritten; - nxsem_wait(&g_syslog_default_sem); + nxsem_wait(&sem); for (nwritten = 0; nwritten < buflen; nwritten++) { up_putc(buffer[nwritten]); } - nxsem_post(&g_syslog_default_sem); + nxsem_post(&sem); #endif return buflen;