From 51a2171c71c562a6710ca23d9a229ee55576aaa3 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Tue, 18 Feb 2020 16:40:59 +0800 Subject: [PATCH] ramlog: Remove g_ramlog_syslog_channel since it's same as g_default_channel And remove syslog_init_e because all initialization is later now and we don't distinguish the initialition phase anymore after ramlog don't need special initialize. --- Documentation/NuttxPortingGuide.html | 24 ++--------- arch/arm/src/common/up_initialize.c | 8 ---- arch/avr/src/common/up_initialize.c | 8 ---- arch/hc/src/common/up_initialize.c | 8 ---- arch/mips/src/common/up_initialize.c | 8 ---- arch/or1k/src/common/up_initialize.c | 8 ---- arch/renesas/src/common/up_initialize.c | 8 ---- arch/risc-v/src/common/up_initialize.c | 8 ---- arch/sim/src/sim/up_initialize.c | 8 ---- arch/x86/src/common/up_initialize.c | 8 ---- arch/xtensa/src/common/xtensa_initialize.c | 8 ---- arch/z16/src/common/up_initialize.c | 8 ---- arch/z80/src/common/up_initialize.c | 8 ---- drivers/syslog/README.txt | 20 ++-------- drivers/syslog/ramlog.c | 46 ++-------------------- drivers/syslog/syslog_filechannel.c | 3 +- drivers/syslog/syslog_initialize.c | 35 +++++----------- include/nuttx/syslog/ramlog.h | 4 +- include/nuttx/syslog/syslog.h | 15 ++----- sched/init/nx_start.c | 2 +- 20 files changed, 26 insertions(+), 219 deletions(-) diff --git a/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index ef2ffdb70e..17f765201a 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/Documentation/NuttxPortingGuide.html @@ -6668,9 +6668,9 @@ int syslog_channel(FAR const struct syslog_channel_s *channel);

Description: @@ -6693,13 +6693,6 @@ int syslog_initialize(enum syslog_init_e phase); If CONFIG_ARCH_SYSLOG is selected, then the architecture-specific logic will provide its own SYSLOG device initialize which must include as a minimum a call to syslog_channel() to use the device. -

Input Parameters: -

Returned Value: Zero (OK) is returned on success; a negated errno value is returned on any failure.

@@ -6707,19 +6700,8 @@ int syslog_initialize(enum syslog_init_e phase); Different types of SYSLOG devices have different OS initialization requirements. Some are available immediately at reset, some are available after some basic OS initialization, and some only after OS is fully - initialized. In order to satisfy these different initialization - requirements, syslog_initialize() is called twice from the boot-up logic: + initialized.

-

There are other types of SYSLOG channel devices that may require even further initialization. For example, the file SYSLOG channel (described below) cannot be initialized until the necessary file systems have been mounted.

diff --git a/arch/arm/src/common/up_initialize.c b/arch/arm/src/common/up_initialize.c index e4d63b8787..7e802f4b61 100644 --- a/arch/arm/src/common/up_initialize.c +++ b/arch/arm/src/common/up_initialize.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -201,13 +200,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/avr/src/common/up_initialize.c b/arch/avr/src/common/up_initialize.c index 7b4cbc1067..4c76df0820 100644 --- a/arch/avr/src/common/up_initialize.c +++ b/arch/avr/src/common/up_initialize.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include @@ -230,13 +229,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/hc/src/common/up_initialize.c b/arch/hc/src/common/up_initialize.c index 95b7a7a79a..3397f04987 100644 --- a/arch/hc/src/common/up_initialize.c +++ b/arch/hc/src/common/up_initialize.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -163,13 +162,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/mips/src/common/up_initialize.c b/arch/mips/src/common/up_initialize.c index a741582bd0..2bab501228 100644 --- a/arch/mips/src/common/up_initialize.c +++ b/arch/mips/src/common/up_initialize.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -165,13 +164,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/or1k/src/common/up_initialize.c b/arch/or1k/src/common/up_initialize.c index e0015f102b..bfc6d42b6f 100644 --- a/arch/or1k/src/common/up_initialize.c +++ b/arch/or1k/src/common/up_initialize.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -256,13 +255,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - /* Print OpenRISC CPU information */ or1k_print_cpuinfo(); diff --git a/arch/renesas/src/common/up_initialize.c b/arch/renesas/src/common/up_initialize.c index 1e040349c3..af513983b0 100644 --- a/arch/renesas/src/common/up_initialize.c +++ b/arch/renesas/src/common/up_initialize.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -149,13 +148,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/risc-v/src/common/up_initialize.c b/arch/risc-v/src/common/up_initialize.c index a6d0191657..989837bab6 100644 --- a/arch/risc-v/src/common/up_initialize.c +++ b/arch/risc-v/src/common/up_initialize.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #include @@ -147,12 +146,5 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - board_autoled_on(LED_IRQSENABLED); } diff --git a/arch/sim/src/sim/up_initialize.c b/arch/sim/src/sim/up_initialize.c index 5ef6abba36..ee2531d780 100644 --- a/arch/sim/src/sim/up_initialize.c +++ b/arch/sim/src/sim/up_initialize.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -240,13 +239,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/x86/src/common/up_initialize.c b/arch/x86/src/common/up_initialize.c index efc6f7345d..82731becb0 100644 --- a/arch/x86/src/common/up_initialize.c +++ b/arch/x86/src/common/up_initialize.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -165,13 +164,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/xtensa/src/common/xtensa_initialize.c b/arch/xtensa/src/common/xtensa_initialize.c index 516146819e..9d92d6efaf 100644 --- a/arch/xtensa/src/common/xtensa_initialize.c +++ b/arch/xtensa/src/common/xtensa_initialize.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -173,13 +172,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/z16/src/common/up_initialize.c b/arch/z16/src/common/up_initialize.c index 51cd2eba5d..4ce2e09e0c 100644 --- a/arch/z16/src/common/up_initialize.c +++ b/arch/z16/src/common/up_initialize.c @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -165,13 +164,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on only minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/arch/z80/src/common/up_initialize.c b/arch/z80/src/common/up_initialize.c index 61556c9ada..beaf3d0e16 100644 --- a/arch/z80/src/common/up_initialize.c +++ b/arch/z80/src/common/up_initialize.c @@ -50,7 +50,6 @@ #include #include #include -#include #include #include #include @@ -164,13 +163,6 @@ void up_initialize(void) ptmx_register(); #endif - /* Early initialization of the system logging device. Some SYSLOG channel - * can be initialized early in the initialization sequence because they - * depend on minimal OS initialization. - */ - - syslog_initialize(SYSLOG_INIT_EARLY); - #if defined(CONFIG_CRYPTO) /* Initialize the HW crypto and /dev/crypto */ diff --git a/drivers/syslog/README.txt b/drivers/syslog/README.txt index dbc46df567..6b8541cd80 100644 --- a/drivers/syslog/README.txt +++ b/drivers/syslog/README.txt @@ -189,9 +189,9 @@ SYSLOG Channels Prototype: #ifndef CONFIG_ARCH_SYSLOG - int syslog_initialize(enum syslog_init_e phase); + int syslog_initialize(void); #else - # define syslog_initialize(phase) + # define syslog_initialize() #endif Description: @@ -209,10 +209,6 @@ SYSLOG Channels logic will provide its own SYSLOG device initialize which must include as a minimum a call to syslog_channel() to use the device. - Input Parameters: - - * phase - One of {SYSLOG_INIT_EARLY, SYSLOG_INIT_LATE} - Returned Value: Zero (OK) is returned on success; a negated errno value is returned on any failure. @@ -220,17 +216,7 @@ SYSLOG Channels Different types of SYSLOG devices have different OS initialization requirements. Some are available immediately at reset, some are available after some basic OS initialization, and some only after OS is fully - initialized. In order to satisfy these different initialization - requirements, syslog_initialize() is called twice from the boot-up logic: - - * syslog_initialize() is called from the architecture-specific - up_initialize() function as some as basic hardware resources have been - initialized: Timers, interrupts, etc. In this case, - syslog_initialize() is called with the argument SYSLOG_INIT_EARLY. - * syslog_initialize() is called again from nx_start() when the full OS - initialization has completed, just before the application main entry - point is spawned. In this case, syslog_initialize() is called with - the argument SYSLOG_INIT_LATE. + initialized. There are other types of SYSLOG channel devices that may require even further initialization. For example, the file SYSLOG channel (described diff --git a/drivers/syslog/ramlog.c b/drivers/syslog/ramlog.c index bbb7670709..7823d4596d 100644 --- a/drivers/syslog/ramlog.c +++ b/drivers/syslog/ramlog.c @@ -93,12 +93,6 @@ struct ramlog_dev_s * Private Function Prototypes ****************************************************************************/ -/* Syslog channel methods */ - -#ifdef CONFIG_RAMLOG_SYSLOG -static int ramlog_flush(void); -#endif - /* Helper functions */ #ifndef CONFIG_RAMLOG_NONBLOCKING @@ -117,19 +111,6 @@ static ssize_t ramlog_write(FAR struct file *filep, FAR const char *buffer, static int ramlog_poll(FAR struct file *filep, FAR struct pollfd *fds, bool setup); -/**************************************************************************** - * Private Data - ****************************************************************************/ - -#ifdef CONFIG_RAMLOG_SYSLOG -static const struct syslog_channel_s g_ramlog_syslog_channel = -{ - ramlog_putc, - ramlog_putc, - ramlog_flush -}; -#endif - /**************************************************************************** * Private Data ****************************************************************************/ @@ -180,17 +161,6 @@ static struct ramlog_dev_s g_sysdev = * Private Functions ****************************************************************************/ -/**************************************************************************** - * Name: ramlog_flush - ****************************************************************************/ - -#ifdef CONFIG_RAMLOG_SYSLOG -static int ramlog_flush(void) -{ - return OK; -} -#endif - /**************************************************************************** * Name: ramlog_readnotify ****************************************************************************/ @@ -720,7 +690,7 @@ int ramlog_register(FAR const char *devpath, FAR char *buffer, size_t buflen) } /**************************************************************************** - * Name: ramlog_syslog_channel + * Name: ramlog_syslog_register * * Description: * Use a pre-allocated RAM logging device and register it at the path @@ -729,21 +699,11 @@ int ramlog_register(FAR const char *devpath, FAR char *buffer, size_t buflen) ****************************************************************************/ #ifdef CONFIG_RAMLOG_SYSLOG -int ramlog_syslog_channel(void) +void ramlog_syslog_register(void) { - int ret; - /* Register the syslog character driver */ - ret = register_driver(CONFIG_SYSLOG_DEVPATH, &g_ramlogfops, 0666, &g_sysdev); - if (ret < 0) - { - return ret; - } - - /* Use the RAMLOG as the SYSLOG channel */ - - return syslog_channel(&g_ramlog_syslog_channel); + register_driver(CONFIG_SYSLOG_DEVPATH, &g_ramlogfops, 0666, &g_sysdev); } #endif diff --git a/drivers/syslog/syslog_filechannel.c b/drivers/syslog/syslog_filechannel.c index e7db19296b..ce6fa1fc3c 100644 --- a/drivers/syslog/syslog_filechannel.c +++ b/drivers/syslog/syslog_filechannel.c @@ -178,8 +178,7 @@ int syslog_file_channel(FAR const char *devpath) { /* We should still be able to back-up and re-initialized everything */ - syslog_initialize(SYSLOG_INIT_EARLY); - syslog_initialize(SYSLOG_INIT_LATE); + syslog_channel(saved_channel); goto errout_with_lock; } diff --git a/drivers/syslog/syslog_initialize.c b/drivers/syslog/syslog_initialize.c index 87c575b2bb..45baf8dac9 100644 --- a/drivers/syslog/syslog_initialize.c +++ b/drivers/syslog/syslog_initialize.c @@ -71,7 +71,7 @@ * as a minimum a call to syslog_channel() to use the device. * * Input Parameters: - * phase - One of {SYSLOG_INIT_EARLY, SYSLOG_INIT_LATE} + * None * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on @@ -79,41 +79,26 @@ * ****************************************************************************/ -int syslog_initialize(enum syslog_init_e phase) +int syslog_initialize(void) { int ret = OK; #if defined(CONFIG_SYSLOG_CHAR) - if (phase == SYSLOG_INIT_LATE) - { - /* Enable use of a character device as the SYSLOG device */ - - ret = syslog_dev_channel(); - } - -#elif defined(CONFIG_RAMLOG_SYSLOG) - if (phase == SYSLOG_INIT_EARLY) - { - /* Use the RAMLOG as the SYSLOG device */ - - ret = ramlog_syslog_channel(); - } + /* Enable use of a character device as the SYSLOG device */ + ret = syslog_dev_channel(); #elif defined(CONFIG_SYSLOG_CONSOLE) - if (phase == SYSLOG_INIT_LATE) - { - /* Use the console device as the SYSLOG device */ + /* Use the console device as the SYSLOG device */ - ret = syslog_console_channel(); - } + ret = syslog_console_channel(); +#endif +#ifdef CONFIG_RAMLOG_SYSLOG + ramlog_syslog_register(); #endif #ifdef CONFIG_SYSLOG_CHARDEV - if (phase == SYSLOG_INIT_EARLY) - { - syslog_register(); - } + syslog_register(); #endif return ret; diff --git a/include/nuttx/syslog/ramlog.h b/include/nuttx/syslog/ramlog.h index c25471ebf1..a764eaef57 100644 --- a/include/nuttx/syslog/ramlog.h +++ b/include/nuttx/syslog/ramlog.h @@ -130,7 +130,7 @@ extern "C" int ramlog_register(FAR const char *devpath, FAR char *buffer, size_t buflen); /**************************************************************************** - * Name: ramlog_syslog_channel + * Name: ramlog_syslog_register * * Description: * Create the RAM logging device and register it at the specified path. @@ -139,7 +139,7 @@ int ramlog_register(FAR const char *devpath, FAR char *buffer, size_t buflen); ****************************************************************************/ #ifdef CONFIG_RAMLOG_SYSLOG -int ramlog_syslog_channel(void); +void ramlog_syslog_register(void); #endif /**************************************************************************** diff --git a/include/nuttx/syslog/syslog.h b/include/nuttx/syslog/syslog.h index cd9a982313..de57bdd99f 100644 --- a/include/nuttx/syslog/syslog.h +++ b/include/nuttx/syslog/syslog.h @@ -97,15 +97,6 @@ * Public Types ****************************************************************************/ -/* Initialization phases */ - -enum syslog_init_e -{ - SYSLOG_INIT_RESET = 0, /* Power on SYSLOG initialization phase */ - SYSLOG_INIT_EARLY, /* Early initialization in up_initialize() */ - SYSLOG_INIT_LATE /* Late initialization in nx_start(). */ -}; - /* This structure provides the interface to a SYSLOG device */ typedef CODE ssize_t (*syslog_write_t)(FAR const char *buf, size_t buflen); @@ -181,7 +172,7 @@ int syslog_channel(FAR const struct syslog_channel_s *channel); * as a minimum a call to syslog_channel() to use the device. * * Input Parameters: - * phase - One of {SYSLOG_INIT_EARLY, SYSLOG_INIT_LATE} + * None * * Returned Value: * Zero (OK) is returned on success; a negated errno value is returned on @@ -190,9 +181,9 @@ int syslog_channel(FAR const struct syslog_channel_s *channel); ****************************************************************************/ #ifndef CONFIG_ARCH_SYSLOG -int syslog_initialize(enum syslog_init_e phase); +int syslog_initialize(void); #else -# define syslog_initialize(phase) +# define syslog_initialize() #endif /**************************************************************************** diff --git a/sched/init/nx_start.c b/sched/init/nx_start.c index 8992cd5d36..c840cb9eaf 100644 --- a/sched/init/nx_start.c +++ b/sched/init/nx_start.c @@ -801,7 +801,7 @@ void nx_start(void) * depend on having IDLE task file structures setup. */ - syslog_initialize(SYSLOG_INIT_LATE); + syslog_initialize(); #ifdef CONFIG_SMP /* Start all CPUs *********************************************************/