You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/06/02 13:45:34 UTC

[incubator-nuttx] 02/02: syslog: support ramlog, up_putc, rpmsg_syslog coexist

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit ed6b257fa404812f4ec64e4303c4e586b67eee5c
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Tue May 18 22:19:37 2021 +0800

    syslog: support ramlog, up_putc, rpmsg_syslog coexist
    
    N/A
    
    Change-Id: Ia58c7e195da7ad48f3018a131a78b2f01f94e741
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 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 08d4ccf..80bca5f 100644
--- a/drivers/syslog/syslog_channel.c
+++ b/drivers/syslog/syslog_channel.c
@@ -33,9 +33,13 @@
 
 #ifdef CONFIG_RAMLOG_SYSLOG
 #  include <nuttx/syslog/ramlog.h>
-#elif defined(CONFIG_SYSLOG_RPMSG)
+#endif
+
+#ifdef CONFIG_SYSLOG_RPMSG
 #  include <nuttx/syslog/syslog_rpmsg.h>
-#elif defined(CONFIG_ARCH_LOWPUTC)
+#endif
+
+#ifdef CONFIG_ARCH_LOWPUTC
 #  include <nuttx/arch.h>
 #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);