From c161dc07a9c42ff57b7624cd825e8701eb1c9127 Mon Sep 17 00:00:00 2001 From: Xiang Xiao Date: Wed, 26 Feb 2020 21:14:02 +0800 Subject: [PATCH] syslog/file: Remove syslog_dev_uninitialize return value To simplify the initializition process --- drivers/syslog/syslog.h | 2 +- drivers/syslog/syslog_device.c | 11 +++++++++-- drivers/syslog/syslog_filechannel.c | 21 +-------------------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/drivers/syslog/syslog.h b/drivers/syslog/syslog.h index 4b9cce9dae..e9623372e6 100644 --- a/drivers/syslog/syslog.h +++ b/drivers/syslog/syslog.h @@ -119,7 +119,7 @@ int syslog_dev_initialize(FAR const char *devpath, int oflags, int mode); ****************************************************************************/ #ifdef CONFIG_SYSLOG_FILE -int syslog_dev_uninitialize(void); +void syslog_dev_uninitialize(void); #endif /* CONFIG_SYSLOG_FILE */ /**************************************************************************** diff --git a/drivers/syslog/syslog_device.c b/drivers/syslog/syslog_device.c index 0036588cf9..498c99335b 100644 --- a/drivers/syslog/syslog_device.c +++ b/drivers/syslog/syslog_device.c @@ -413,8 +413,15 @@ int syslog_dev_initialize(FAR const char *devpath, int oflags, int mode) ****************************************************************************/ #ifdef CONFIG_SYSLOG_FILE /* Currently only used in this configuration */ -int syslog_dev_uninitialize(void) +void syslog_dev_uninitialize(void) { + /* Check if the system is ready */ + + if (syslog_dev_outputready() < 0) + { + return; + } + /* Attempt to flush any buffered data */ sched_lock(); @@ -422,6 +429,7 @@ int syslog_dev_uninitialize(void) /* Close the detached file instance */ + g_syslog_dev.sl_state = SYSLOG_UNINITIALIZED; file_close(&g_syslog_dev.sl_file); /* Free the device path */ @@ -439,7 +447,6 @@ int syslog_dev_uninitialize(void) memset(&g_syslog_dev, 0, sizeof(struct syslog_dev_s)); sched_unlock(); - return OK; } #endif /* CONFIG_SYSLOG_FILE */ diff --git a/drivers/syslog/syslog_filechannel.c b/drivers/syslog/syslog_filechannel.c index ce6fa1fc3c..40f854ea92 100644 --- a/drivers/syslog/syslog_filechannel.c +++ b/drivers/syslog/syslog_filechannel.c @@ -139,7 +139,6 @@ static int syslog_file_force(int ch) int syslog_file_channel(FAR const char *devpath) { - FAR const struct syslog_channel_s *saved_channel; int ret; /* Reset the default SYSLOG channel so that we can safely modify the @@ -151,34 +150,16 @@ int syslog_file_channel(FAR const char *devpath) */ sched_lock(); - saved_channel = g_syslog_channel; - ret = syslog_channel(&g_default_channel); - if (ret < 0) - { - goto errout_with_lock; - } /* Uninitialize any driver interface that may have been in place */ - ret = syslog_dev_uninitialize(); - if (ret < 0) - { - /* Nothing fatal has happened yet, we can restore the last channel - * since it was not uninitialized (was it?) - */ - - syslog_channel(saved_channel); - goto errout_with_lock; - } + syslog_dev_uninitialize(); /* Then initialize the file interface */ ret = syslog_dev_initialize(devpath, OPEN_FLAGS, OPEN_MODE); if (ret < 0) { - /* We should still be able to back-up and re-initialized everything */ - - syslog_channel(saved_channel); goto errout_with_lock; }