Skip to content

Commit

Permalink
syslog/channel: move syslog channel map into rodata
Browse files Browse the repository at this point in the history
add SYSLOG_REGISTER to support disable syslog channel register

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao committed Sep 26, 2024
1 parent c423dfb commit 466d672
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions arch/arm/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
8 changes: 8 additions & 0 deletions drivers/syslog/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
6 changes: 5 additions & 1 deletion drivers/syslog/syslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 7 additions & 2 deletions drivers/syslog/syslog_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -369,3 +373,4 @@ int syslog_channel_unregister(FAR syslog_channel_t *channel)

return -EINVAL;
}
#endif

0 comments on commit 466d672

Please sign in to comment.