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 23, 2024
1 parent 4d25c02 commit c7ee778
Show file tree
Hide file tree
Showing 22 changed files with 89 additions and 84 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
3 changes: 1 addition & 2 deletions drivers/syslog/syslog.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ extern "C"
*/

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
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
24 changes: 12 additions & 12 deletions drivers/syslog/syslog_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ enum syslog_dev_state

struct syslog_dev_s
{
struct syslog_channel_s channel;
syslog_channel_t channel;

uint8_t sl_state; /* See enum syslog_dev_state */
uint8_t sl_oflags; /* Saved open mode (for re-open) */
Expand All @@ -88,11 +88,11 @@ struct syslog_dev_s
* Private Function Prototypes
****************************************************************************/

static ssize_t syslog_dev_write(FAR struct syslog_channel_s *channel,
static ssize_t syslog_dev_write(FAR syslog_channel_t *channel,
FAR const char *buffer, size_t buflen);
static int syslog_dev_putc(FAR struct syslog_channel_s *channel, int ch);
static int syslog_dev_force(FAR struct syslog_channel_s *channel, int ch);
static int syslog_dev_flush(FAR struct syslog_channel_s *channel);
static int syslog_dev_putc(FAR syslog_channel_t *channel, int ch);
static int syslog_dev_force(FAR syslog_channel_t *channel, int ch);
static int syslog_dev_flush(FAR syslog_channel_t *channel);

/****************************************************************************
* Private Data
Expand Down Expand Up @@ -373,7 +373,7 @@ static int syslog_dev_outputready(FAR struct syslog_dev_s *syslog_dev)
*
****************************************************************************/

static ssize_t syslog_dev_write(FAR struct syslog_channel_s *channel,
static ssize_t syslog_dev_write(FAR syslog_channel_t *channel,
FAR const char *buffer, size_t buflen)
{
FAR struct syslog_dev_s *syslog_dev = (FAR struct syslog_dev_s *)channel;
Expand Down Expand Up @@ -526,7 +526,7 @@ static ssize_t syslog_dev_write(FAR struct syslog_channel_s *channel,
*
****************************************************************************/

static int syslog_dev_putc(FAR struct syslog_channel_s *channel, int ch)
static int syslog_dev_putc(FAR syslog_channel_t *channel, int ch)
{
FAR struct syslog_dev_s *syslog_dev = (FAR struct syslog_dev_s *)channel;
ssize_t nbytes;
Expand Down Expand Up @@ -619,7 +619,7 @@ static int syslog_dev_putc(FAR struct syslog_channel_s *channel, int ch)
*
****************************************************************************/

static int syslog_dev_force(FAR struct syslog_channel_s *channel, int ch)
static int syslog_dev_force(FAR syslog_channel_t *channel, int ch)
{
UNUSED(channel);
return ch;
Expand All @@ -639,7 +639,7 @@ static int syslog_dev_force(FAR struct syslog_channel_s *channel, int ch)
*
****************************************************************************/

static int syslog_dev_flush(FAR struct syslog_channel_s *channel)
static int syslog_dev_flush(FAR syslog_channel_t *channel)
{
#if defined(CONFIG_SYSLOG_FILE) && !defined(CONFIG_DISABLE_MOUNTPOINT)
FAR struct syslog_dev_s *syslog_dev = (FAR struct syslog_dev_s *)channel;
Expand Down Expand Up @@ -687,7 +687,7 @@ static int syslog_dev_flush(FAR struct syslog_channel_s *channel)
*
****************************************************************************/

FAR struct syslog_channel_s *syslog_dev_initialize(FAR const char *devpath,
FAR syslog_channel_t *syslog_dev_initialize(FAR const char *devpath,
int oflags, int mode)
{
FAR struct syslog_dev_s *syslog_dev;
Expand All @@ -703,7 +703,7 @@ FAR struct syslog_channel_s *syslog_dev_initialize(FAR const char *devpath,

syslog_dev->channel.sc_ops = &g_syslog_dev_ops;

return (FAR struct syslog_channel_s *)syslog_dev;
return (FAR syslog_channel_t *)syslog_dev;
}

/****************************************************************************
Expand All @@ -726,7 +726,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)
{
FAR struct syslog_dev_s *syslog_dev = (FAR struct syslog_dev_s *)channel;

Expand Down
4 changes: 2 additions & 2 deletions drivers/syslog/syslog_filechannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,9 @@ static void log_rotate(FAR const char *log_file)
*
****************************************************************************/

FAR struct syslog_channel_s *syslog_file_channel(FAR const char *devpath)
FAR syslog_channel_t *syslog_file_channel(FAR const char *devpath)
{
FAR struct syslog_channel_s *file_channel;
FAR syslog_channel_t *file_channel;
irqstate_t flags;

/* Reset the default SYSLOG channel so that we can safely modify the
Expand Down
2 changes: 1 addition & 1 deletion drivers/syslog/syslog_flush.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ int syslog_flush(void)

for (i = 0; i < CONFIG_SYSLOG_MAX_CHANNELS; i++)
{
FAR struct syslog_channel_s *channel = g_syslog_channel[i];
FAR syslog_channel_t *channel = g_syslog_channel[i];

if (channel == NULL)
{
Expand Down
Loading

0 comments on commit c7ee778

Please sign in to comment.