From ed6b257fa404812f4ec64e4303c4e586b67eee5c Mon Sep 17 00:00:00 2001 From: Jiuzhu Dong Date: Tue, 18 May 2021 22:19:37 +0800 Subject: [PATCH] syslog: support ramlog, up_putc, rpmsg_syslog coexist N/A Change-Id: Ia58c7e195da7ad48f3018a131a78b2f01f94e741 Signed-off-by: Jiuzhu Dong --- drivers/syslog/syslog_channel.c | 52 ++++++++++++++++++++++++--------- 1 file changed, 38 insertions(+), 14 deletions(-) diff --git a/drivers/syslog/syslog_channel.c b/drivers/syslog/syslog_channel.c index 08d4ccfd30..80bca5fb82 100644 --- a/drivers/syslog/syslog_channel.c +++ b/drivers/syslog/syslog_channel.c @@ -33,9 +33,13 @@ #ifdef CONFIG_RAMLOG_SYSLOG # include -#elif defined(CONFIG_SYSLOG_RPMSG) +#endif + +#ifdef CONFIG_SYSLOG_RPMSG # include -#elif defined(CONFIG_ARCH_LOWPUTC) +#endif + +#ifdef CONFIG_ARCH_LOWPUTC # include #endif @@ -45,15 +49,11 @@ * Private Function Prototypes ****************************************************************************/ -#if !defined(CONFIG_RAMLOG_SYSLOG) && !defined(CONFIG_SYSLOG_RPMSG) -# define NEED_LOWPUTC -#endif - /**************************************************************************** * Private Function Prototypes ****************************************************************************/ -#ifdef NEED_LOWPUTC +#if defined(CONFIG_SYSLOG_DEFAULT) static int syslog_default_putc(FAR struct syslog_channel_s *channel, int ch); #endif @@ -63,38 +63,62 @@ static int syslog_default_putc(FAR struct syslog_channel_s *channel, ****************************************************************************/ #if defined(CONFIG_RAMLOG_SYSLOG) -static const struct syslog_channel_ops_s g_default_channel_ops = +static const struct syslog_channel_ops_s g_ramlog_channel_ops = { ramlog_putc, ramlog_putc }; -#elif defined(CONFIG_SYSLOG_RPMSG) -static const struct syslog_channel_ops_s g_default_channel_ops = + +static struct syslog_channel_s g_ramlog_channel = +{ + &g_ramlog_channel_ops +}; +#endif + +#if defined(CONFIG_SYSLOG_RPMSG) +static const struct syslog_channel_ops_s g_rpmsg_channel_ops = { syslog_rpmsg_putc, syslog_rpmsg_putc, syslog_rpmsg_flush, syslog_rpmsg_write }; -#else + +static struct syslog_channel_s g_rpmsg_channel = +{ + &g_rpmsg_channel_ops +}; +#endif + +#if defined(CONFIG_SYSLOG_DEFAULT) static const struct syslog_channel_ops_s g_default_channel_ops = { syslog_default_putc, syslog_default_putc }; -#endif static struct syslog_channel_s g_default_channel = { &g_default_channel_ops }; +#endif /* This is the current syslog channel in use */ FAR struct syslog_channel_s *g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] = { - &g_default_channel +#if defined(CONFIG_SYSLOG_DEFAULT) + &g_default_channel, +#endif + +#if defined(CONFIG_RAMLOG_SYSLOG) + &g_ramlog_channel, +#endif + +#if defined(CONFIG_SYSLOG_RPMSG) + &g_rpmsg_channel +#endif }; /**************************************************************************** @@ -110,7 +134,7 @@ FAR struct syslog_channel_s * ****************************************************************************/ -#ifdef NEED_LOWPUTC +#if defined(CONFIG_SYSLOG_DEFAULT) static int syslog_default_putc(FAR struct syslog_channel_s *channel, int ch) { UNUSED(channel);