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 2024/09/26 08:10:38 UTC
(nuttx) 02/02: syslog/channel: move syslog channel map into rodata
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/nuttx.git
commit a04e44ea758b62b3da7404fa74a7e43108179efb
Author: chao an <an...@lixiang.com>
AuthorDate: Thu Sep 26 10:16:21 2024 +0800
syslog/channel: move syslog channel map into rodata
add SYSLOG_REGISTER to support disable syslog channel register
Signed-off-by: chao an <an...@lixiang.com>
---
arch/arm/Kconfig | 1 +
drivers/syslog/Kconfig | 8 ++++++++
drivers/syslog/syslog.h | 6 +++++-
drivers/syslog/syslog_channel.c | 9 +++++++--
4 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
index 846ce91063..24d5999fe8 100644
--- a/arch/arm/Kconfig
+++ b/arch/arm/Kconfig
@@ -1374,6 +1374,7 @@ config DEBUG_SECUREFAULT
config ARM_SEMIHOSTING_SYSLOG
bool "Semihosting SYSLOG support"
select ARCH_SYSLOG
+ select SYSLOG_REGISTER
---help---
Enable hooks to support semihosting syslog output.
diff --git a/drivers/syslog/Kconfig b/drivers/syslog/Kconfig
index 9753aa4417..372f5b68b7 100644
--- a/drivers/syslog/Kconfig
+++ b/drivers/syslog/Kconfig
@@ -196,6 +196,7 @@ if !ARCH_SYSLOG
config SYSLOG_CHAR
bool "Log to a character device"
default n
+ select SYSLOG_REGISTER
---help---
Enable the generic character device for the SYSLOG. The full path to the
SYSLOG device is provided by SYSLOG_DEVPATH. A valid character device (or
@@ -231,6 +232,7 @@ config SYSLOG_CONSOLE
bool "Log to /dev/console"
default !ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_RTT
depends on DEV_CONSOLE
+ select SYSLOG_REGISTER
---help---
Use the system console as a SYSLOG output device.
@@ -291,6 +293,7 @@ config SYSLOG_RPMSG_SERVER_CHARDEV
menuconfig SYSLOG_FILE
bool "Syslog file output"
default n
+ select SYSLOG_REGISTER
---help---
Build in support to use a file to collect SYSLOG output. File SYSLOG
channels differ from other SYSLOG channels in that they cannot be
@@ -375,4 +378,9 @@ config SYSLOG_IOCTL
commands are SYSLOGIOC_SETFILTER/SYSLOGIOC_GETCHANNELS, which can be
used to set the enable status of different channels
+config SYSLOG_REGISTER
+ bool "Register syslog channel support"
+ ---help---
+ This option will support register the syslog channel dynamically.
+
endmenu # System logging
diff --git a/drivers/syslog/syslog.h b/drivers/syslog/syslog.h
index b66212fbc8..e86210353a 100644
--- a/drivers/syslog/syslog.h
+++ b/drivers/syslog/syslog.h
@@ -47,7 +47,11 @@ extern "C"
* g_default_channel.
*/
-EXTERN FAR syslog_channel_t *g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS];
+EXTERN FAR syslog_channel_t *
+#ifndef CONFIG_SYSLOG_REGISTER
+const
+#endif
+g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS];
/****************************************************************************
* Public Function Prototypes
diff --git a/drivers/syslog/syslog_channel.c b/drivers/syslog/syslog_channel.c
index c370fd37ec..fc8465cdcf 100644
--- a/drivers/syslog/syslog_channel.c
+++ b/drivers/syslog/syslog_channel.c
@@ -191,8 +191,11 @@ static syslog_channel_t g_default_channel =
/* This is the current syslog channel in use */
-FAR syslog_channel_t
-*g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
+FAR syslog_channel_t *
+#ifndef CONFIG_SYSLOG_REGISTER
+const
+#endif
+g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
{
#if defined(CONFIG_SYSLOG_DEFAULT)
&g_default_channel,
@@ -272,6 +275,7 @@ static ssize_t syslog_default_write(FAR syslog_channel_t *channel,
*
****************************************************************************/
+#ifdef CONFIG_SYSLOG_REGISTER
int syslog_channel_register(FAR syslog_channel_t *channel)
{
#if (CONFIG_SYSLOG_MAX_CHANNELS != 1)
@@ -369,3 +373,4 @@ int syslog_channel_unregister(FAR syslog_channel_t *channel)
return -EINVAL;
}
+#endif