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 25, 2024
1 parent 5892fb9 commit 9401f1d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
10 changes: 9 additions & 1 deletion 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
depends on 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 @@ -230,7 +231,7 @@ config SYSLOG_STREAM
config SYSLOG_CONSOLE
bool "Log to /dev/console"
default !ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_RTT
depends on DEV_CONSOLE
depends on DEV_CONSOLE && SYSLOG_REGISTER
---help---
Use the system console as a SYSLOG output device.

Expand Down Expand Up @@ -291,6 +292,7 @@ config SYSLOG_RPMSG_SERVER_CHARDEV
menuconfig SYSLOG_FILE
bool "Syslog file output"
default n
depends on 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 +377,10 @@ 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"
default y
---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 @@ -48,7 +48,11 @@ extern "C"
*/

struct syslog_channel_s; /* Forward reference */
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 9401f1d

Please sign in to comment.