Skip to content

Commit 466d672

Browse files
committed
syslog/channel: move syslog channel map into rodata
add SYSLOG_REGISTER to support disable syslog channel register Signed-off-by: chao an <anchao@lixiang.com>
1 parent c423dfb commit 466d672

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

arch/arm/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,7 @@ config DEBUG_SECUREFAULT
13741374
config ARM_SEMIHOSTING_SYSLOG
13751375
bool "Semihosting SYSLOG support"
13761376
select ARCH_SYSLOG
1377+
select SYSLOG_REGISTER
13771378
---help---
13781379
Enable hooks to support semihosting syslog output.
13791380

drivers/syslog/Kconfig

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ if !ARCH_SYSLOG
196196
config SYSLOG_CHAR
197197
bool "Log to a character device"
198198
default n
199+
select SYSLOG_REGISTER
199200
---help---
200201
Enable the generic character device for the SYSLOG. The full path to the
201202
SYSLOG device is provided by SYSLOG_DEVPATH. A valid character device (or
@@ -231,6 +232,7 @@ config SYSLOG_CONSOLE
231232
bool "Log to /dev/console"
232233
default !ARCH_LOWPUTC && !SYSLOG_CHAR && !RAMLOG_SYSLOG && !SYSLOG_RPMSG && !SYSLOG_RTT
233234
depends on DEV_CONSOLE
235+
select SYSLOG_REGISTER
234236
---help---
235237
Use the system console as a SYSLOG output device.
236238

@@ -291,6 +293,7 @@ config SYSLOG_RPMSG_SERVER_CHARDEV
291293
menuconfig SYSLOG_FILE
292294
bool "Syslog file output"
293295
default n
296+
select SYSLOG_REGISTER
294297
---help---
295298
Build in support to use a file to collect SYSLOG output. File SYSLOG
296299
channels differ from other SYSLOG channels in that they cannot be
@@ -375,4 +378,9 @@ config SYSLOG_IOCTL
375378
commands are SYSLOGIOC_SETFILTER/SYSLOGIOC_GETCHANNELS, which can be
376379
used to set the enable status of different channels
377380

381+
config SYSLOG_REGISTER
382+
bool "Register syslog channel support"
383+
---help---
384+
This option will support register the syslog channel dynamically.
385+
378386
endmenu # System logging

drivers/syslog/syslog.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,11 @@ extern "C"
4747
* g_default_channel.
4848
*/
4949

50-
EXTERN FAR syslog_channel_t *g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS];
50+
EXTERN FAR syslog_channel_t *
51+
#ifndef CONFIG_SYSLOG_REGISTER
52+
const
53+
#endif
54+
g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS];
5155

5256
/****************************************************************************
5357
* Public Function Prototypes

drivers/syslog/syslog_channel.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,11 @@ static syslog_channel_t g_default_channel =
191191

192192
/* This is the current syslog channel in use */
193193

194-
FAR syslog_channel_t
195-
*g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
194+
FAR syslog_channel_t *
195+
#ifndef CONFIG_SYSLOG_REGISTER
196+
const
197+
#endif
198+
g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
196199
{
197200
#if defined(CONFIG_SYSLOG_DEFAULT)
198201
&g_default_channel,
@@ -272,6 +275,7 @@ static ssize_t syslog_default_write(FAR syslog_channel_t *channel,
272275
*
273276
****************************************************************************/
274277

278+
#ifdef CONFIG_SYSLOG_REGISTER
275279
int syslog_channel_register(FAR syslog_channel_t *channel)
276280
{
277281
#if (CONFIG_SYSLOG_MAX_CHANNELS != 1)
@@ -369,3 +373,4 @@ int syslog_channel_unregister(FAR syslog_channel_t *channel)
369373

370374
return -EINVAL;
371375
}
376+
#endif

0 commit comments

Comments
 (0)