Skip to content

Commit

Permalink
syslog/channel: add constant attribute if SYSLOG_IOCTL is not enabled
Browse files Browse the repository at this point in the history
move all private channel define from data to rodata

Signed-off-by: chao an <[email protected]>
  • Loading branch information
anchao committed Sep 26, 2024
1 parent 4195851 commit c423dfb
Show file tree
Hide file tree
Showing 22 changed files with 94 additions and 91 deletions.
4 changes: 2 additions & 2 deletions Documentation/components/drivers/special/syslog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ defined in ``include/nuttx/syslog/syslog.h``:
The channel interface is instantiated by calling
:c:func:`syslog_channel_register()`.

.. c:function:: int syslog_channel_register(FAR const struct syslog_channel_s *channel);
.. c:function:: int syslog_channel_register(FAR syslog_channel_t *channel);
Configure the SYSLOG function to use the provided
channel to generate SYSLOG output.
Expand Down Expand Up @@ -408,7 +408,7 @@ mounting of the file systems.
The interface ``syslog_file_channel()`` is used to configure the
SYSLOG file channel:

.. c:function:: FAR struct syslog_channel_s * \
.. c:function:: FAR syslog_channel_t * \
syslog_file_channel(FAR const char *devpath);
Configure to use a file in a mounted file system
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/src/armv7-m/arm_itm_syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@

/* SYSLOG channel methods */

static int itm_putc(struct syslog_channel_s *channel, int ch);
static int itm_flush(struct syslog_channel_s *channel);
static int itm_putc(syslog_channel_t *channel, int ch);
static int itm_flush(syslog_channel_t *channel);

/****************************************************************************
* Private Data
Expand All @@ -80,7 +80,7 @@ static const struct syslog_channel_ops_s g_itm_channel_ops =

/* This structure describes the ITM SYSLOG channel */

static struct syslog_channel_s g_itm_channel =
static syslog_channel_t g_itm_channel =
{
.sc_ops = &g_itm_channel_ops
};
Expand All @@ -97,7 +97,7 @@ static struct syslog_channel_s g_itm_channel =
*
****************************************************************************/

static int itm_putc(struct syslog_channel_s *channel, int ch)
static int itm_putc(syslog_channel_t *channel, int ch)
{
UNUSED(channel);

Expand Down Expand Up @@ -127,7 +127,7 @@ static int itm_putc(struct syslog_channel_s *channel, int ch)
*
****************************************************************************/

static int itm_flush(struct syslog_channel_s *channel)
static int itm_flush(syslog_channel_t *channel)
{
UNUSED(channel);
return OK;
Expand Down
10 changes: 5 additions & 5 deletions arch/arm/src/armv8-m/arm_itm_syslog.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@

/* SYSLOG channel methods */

static int itm_putc(struct syslog_channel_s *channel, int ch);
static int itm_flush(struct syslog_channel_s *channel);
static int itm_putc(syslog_channel_t *channel, int ch);
static int itm_flush(syslog_channel_t *channel);

/****************************************************************************
* Private Data
Expand All @@ -80,7 +80,7 @@ static const struct syslog_channel_ops_s g_itm_channel_ops =

/* This structure describes the ITM SYSLOG channel */

static struct syslog_channel_s g_itm_channel =
static syslog_channel_t g_itm_channel =
{
.sc_ops = &g_itm_channel_ops
};
Expand All @@ -97,7 +97,7 @@ static struct syslog_channel_s g_itm_channel =
*
****************************************************************************/

static int itm_putc(struct syslog_channel_s *channel, int ch)
static int itm_putc(syslog_channel_t *channel, int ch)
{
UNUSED(channel);

Expand Down Expand Up @@ -127,7 +127,7 @@ static int itm_putc(struct syslog_channel_s *channel, int ch)
*
****************************************************************************/

static int itm_flush(struct syslog_channel_s *channel)
static int itm_flush(syslog_channel_t *channel)
{
UNUSED(channel);
return OK;
Expand Down
2 changes: 1 addition & 1 deletion boards/arm/stm32/clicker2-stm32/src/stm32_appinit.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ int board_app_initialize(uintptr_t arg)

nxsig_usleep(CONFIG_CLICKER2_STM32_SYSLOG_FILE_DELAY * 1000);

struct syslog_channel_s *channel;
syslog_channel_t *channel;
channel = syslog_file_channel(CONFIG_CLICKER2_STM32_SYSLOG_FILE_PATH);
if (channel == NULL)
{
Expand Down
4 changes: 2 additions & 2 deletions drivers/segger/syslog_rtt.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@
* Public Functions
****************************************************************************/

int syslog_rtt_putc(FAR struct syslog_channel_s *channel, int ch)
int syslog_rtt_putc(FAR syslog_channel_t *channel, int ch)
{
SEGGER_RTT_BLOCK_IF_FIFO_FULL(CONFIG_SYSLOG_RTT_CHANNEL);
SEGGER_RTT_PutChar(CONFIG_SYSLOG_RTT_CHANNEL, ch);
return ch;
}

ssize_t syslog_rtt_write(FAR struct syslog_channel_s *channel,
ssize_t syslog_rtt_write(FAR syslog_channel_t *channel,
FAR const char *buffer, size_t buflen)
{
SEGGER_RTT_BLOCK_IF_FIFO_FULL(CONFIG_SYSLOG_RTT_CHANNEL);
Expand Down
4 changes: 2 additions & 2 deletions drivers/syslog/ramlog.c
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ void ramlog_syslog_register(void)
****************************************************************************/

#ifdef CONFIG_RAMLOG_SYSLOG
int ramlog_putc(FAR struct syslog_channel_s *channel, int ch)
int ramlog_putc(FAR syslog_channel_t *channel, int ch)
{
char cch = ch;

Expand All @@ -747,7 +747,7 @@ int ramlog_putc(FAR struct syslog_channel_s *channel, int ch)
return ch;
}

ssize_t ramlog_write(FAR struct syslog_channel_s *channel,
ssize_t ramlog_write(FAR syslog_channel_t *channel,
FAR const char *buffer, size_t buflen)
{
return ramlog_addbuf(&g_sysdev, buffer, buflen);
Expand Down
14 changes: 6 additions & 8 deletions drivers/syslog/syslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,7 @@ extern "C"
* g_default_channel.
*/

struct syslog_channel_s; /* Forward reference */
EXTERN FAR struct syslog_channel_s *g_syslog_channel
[CONFIG_SYSLOG_MAX_CHANNELS];
EXTERN FAR syslog_channel_t *g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS];

/****************************************************************************
* Public Function Prototypes
Expand Down Expand Up @@ -81,8 +79,8 @@ EXTERN FAR struct syslog_channel_s *g_syslog_channel
*
****************************************************************************/

FAR struct syslog_channel_s *syslog_dev_initialize(FAR const char *devpath,
int oflags, int mode);
FAR syslog_channel_t *syslog_dev_initialize(FAR const char *devpath,
int oflags, int mode);

/****************************************************************************
* Name: syslog_dev_uninitialize
Expand All @@ -100,7 +98,7 @@ FAR struct syslog_channel_s *syslog_dev_initialize(FAR const char *devpath,
*
****************************************************************************/

void syslog_dev_uninitialize(FAR struct syslog_channel_s *channel);
void syslog_dev_uninitialize(FAR syslog_channel_t *channel);

/****************************************************************************
* Name: syslog_dev_channel
Expand All @@ -127,7 +125,7 @@ void syslog_dev_uninitialize(FAR struct syslog_channel_s *channel);
****************************************************************************/

#ifdef CONFIG_SYSLOG_CHAR
FAR struct syslog_channel_s *syslog_dev_channel(void);
FAR syslog_channel_t *syslog_dev_channel(void);
#endif

/****************************************************************************
Expand Down Expand Up @@ -158,7 +156,7 @@ FAR struct syslog_channel_s *syslog_dev_channel(void);
****************************************************************************/

#ifdef CONFIG_SYSLOG_CONSOLE
FAR struct syslog_channel_s *syslog_console_channel(void);
FAR syslog_channel_t *syslog_console_channel(void);
#endif

/****************************************************************************
Expand Down
22 changes: 11 additions & 11 deletions drivers/syslog/syslog_channel.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
****************************************************************************/

#if defined(CONFIG_SYSLOG_DEFAULT)
static int syslog_default_putc(FAR struct syslog_channel_s *channel,
static int syslog_default_putc(FAR syslog_channel_t *channel,
int ch);
static ssize_t syslog_default_write(FAR struct syslog_channel_s *channel,
static ssize_t syslog_default_write(FAR syslog_channel_t *channel,
FAR const char *buffer, size_t buflen);
#endif

Expand All @@ -83,7 +83,7 @@ static const struct syslog_channel_ops_s g_ramlog_channel_ops =
ramlog_write
};

static struct syslog_channel_s g_ramlog_channel =
static syslog_channel_t g_ramlog_channel =
{
&g_ramlog_channel_ops
# ifdef CONFIG_SYSLOG_IOCTL
Expand All @@ -103,7 +103,7 @@ static const struct syslog_channel_ops_s g_rpmsg_channel_ops =
syslog_rpmsg_write
};

static struct syslog_channel_s g_rpmsg_channel =
static syslog_channel_t g_rpmsg_channel =
{
&g_rpmsg_channel_ops
# ifdef CONFIG_SYSLOG_IOCTL
Expand All @@ -123,7 +123,7 @@ static const struct syslog_channel_ops_s g_rtt_channel_ops =
syslog_rtt_write
};

static struct syslog_channel_s g_rtt_channel =
static syslog_channel_t g_rtt_channel =
{
&g_rtt_channel_ops
# ifdef CONFIG_SYSLOG_IOCTL
Expand All @@ -142,7 +142,7 @@ static const struct syslog_channel_ops_s g_default_channel_ops =
syslog_default_write
};

static struct syslog_channel_s g_default_channel =
static syslog_channel_t g_default_channel =
{
&g_default_channel_ops
# ifdef CONFIG_SYSLOG_IOCTL
Expand Down Expand Up @@ -191,7 +191,7 @@ static struct syslog_channel_s g_default_channel =

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

FAR struct syslog_channel_s
FAR syslog_channel_t
*g_syslog_channel[CONFIG_SYSLOG_MAX_CHANNELS] =
{
#if defined(CONFIG_SYSLOG_DEFAULT)
Expand Down Expand Up @@ -225,7 +225,7 @@ FAR struct syslog_channel_s
****************************************************************************/

#if defined(CONFIG_SYSLOG_DEFAULT)
static int syslog_default_putc(FAR struct syslog_channel_s *channel, int ch)
static int syslog_default_putc(FAR syslog_channel_t *channel, int ch)
{
UNUSED(channel);

Expand All @@ -236,7 +236,7 @@ static int syslog_default_putc(FAR struct syslog_channel_s *channel, int ch)
#endif
}

static ssize_t syslog_default_write(FAR struct syslog_channel_s *channel,
static ssize_t syslog_default_write(FAR syslog_channel_t *channel,
FAR const char *buffer, size_t buflen)
{
#if defined(CONFIG_ARCH_LOWPUTC)
Expand Down Expand Up @@ -272,7 +272,7 @@ static ssize_t syslog_default_write(FAR struct syslog_channel_s *channel,
*
****************************************************************************/

int syslog_channel_register(FAR struct syslog_channel_s *channel)
int syslog_channel_register(FAR syslog_channel_t *channel)
{
#if (CONFIG_SYSLOG_MAX_CHANNELS != 1)
int i;
Expand Down Expand Up @@ -328,7 +328,7 @@ int syslog_channel_register(FAR struct syslog_channel_s *channel)
*
****************************************************************************/

int syslog_channel_unregister(FAR struct syslog_channel_s *channel)
int syslog_channel_unregister(FAR syslog_channel_t *channel)
{
int i;

Expand Down
2 changes: 1 addition & 1 deletion drivers/syslog/syslog_chardev.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int syslog_chardev_ioctl(FAR struct file *filep,
int cmd, unsigned long arg)
{
FAR struct syslog_channel_info_s *info;
FAR struct syslog_channel_s *channel = NULL;
FAR syslog_channel_t *channel = NULL;
int i;

if (arg == 0)
Expand Down
4 changes: 2 additions & 2 deletions drivers/syslog/syslog_consolechannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
*
****************************************************************************/

FAR struct syslog_channel_s *syslog_console_channel(void)
FAR syslog_channel_t *syslog_console_channel(void)
{
FAR struct syslog_channel_s *console_channel;
FAR syslog_channel_t *console_channel;

/* Initialize the character driver interface */

Expand Down
4 changes: 2 additions & 2 deletions drivers/syslog/syslog_devchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,9 @@
*
****************************************************************************/

FAR struct syslog_channel_s *syslog_dev_channel(void)
FAR syslog_channel_t *syslog_dev_channel(void)
{
FAR struct syslog_channel_s *dev_channel;
FAR syslog_channel_t *dev_channel;

/* Initialize the character driver interface */

Expand Down
Loading

0 comments on commit c423dfb

Please sign in to comment.