diff --git a/include/shell/shell.h b/include/shell/shell.h index e0092d44e0b..d687521926c 100644 --- a/include/shell/shell.h +++ b/include/shell/shell.h @@ -731,7 +731,7 @@ extern void z_shell_print_stream(const void *user_ctx, const char *data, static const struct shell _name; \ static struct shell_ctx UTIL_CAT(_name, _ctx); \ static uint8_t _name##_out_buffer[CONFIG_SHELL_PRINTF_BUFF_SIZE]; \ - SHELL_LOG_BACKEND_DEFINE(_name, _name##_out_buffer, \ + Z_SHELL_LOG_BACKEND_DEFINE(_name, _name##_out_buffer, \ CONFIG_SHELL_PRINTF_BUFF_SIZE, \ _log_queue_size, _log_timeout); \ Z_SHELL_HISTORY_DEFINE(_name##_history, CONFIG_SHELL_HISTORY_BUFFER); \ @@ -751,7 +751,7 @@ extern void z_shell_print_stream(const void *user_ctx, const char *data, .shell_flag = _shell_flag, \ .fprintf_ctx = &_name##_fprintf, \ .stats = SHELL_STATS_PTR(_name), \ - .log_backend = SHELL_LOG_BACKEND_PTR(_name), \ + .log_backend = Z_SHELL_LOG_BACKEND_PTR(_name), \ LOG_INSTANCE_PTR_INIT(log, shell, _name) \ .thread_name = STRINGIFY(_name), \ .thread = &_name##_thread, \ diff --git a/include/shell/shell_log_backend.h b/include/shell/shell_log_backend.h index abdeecef0b0..cd255c0525e 100644 --- a/include/shell/shell_log_backend.h +++ b/include/shell/shell_log_backend.h @@ -47,9 +47,9 @@ struct shell_log_backend_msg { }; /** @brief Prototype of function outputing processed data. */ -int shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx); +int z_shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx); -/** @def SHELL_LOG_BACKEND_DEFINE +/** @def Z_SHELL_LOG_BACKEND_DEFINE * @brief Macro for creating instance of shell log backend. * * @param _name Shell name. @@ -59,31 +59,31 @@ int shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx); * @param _timeout Timeout in milliseconds for pending on queue full. * Message is dropped on timeout. */ -/** @def SHELL_LOG_BACKEND_PTR +/** @def Z_SHELL_LOG_BACKEND_PTR * @brief Macro for retrieving pointer to the instance of shell log backend. * * @param _name Shell name. */ #ifdef CONFIG_SHELL_LOG_BACKEND -#define SHELL_LOG_BACKEND_DEFINE(_name, _buf, _size, _queue_size, _timeout) \ - LOG_BACKEND_DEFINE(_name##_backend, log_backend_shell_api, false); \ - K_MSGQ_DEFINE(_name##_msgq, sizeof(struct shell_log_backend_msg), \ - _queue_size, sizeof(void *)); \ - LOG_OUTPUT_DEFINE(_name##_log_output, shell_log_backend_output_func, \ - _buf, _size); \ - static struct shell_log_backend_control_block _name##_control_block; \ - static const struct shell_log_backend _name##_log_backend = { \ - .backend = &_name##_backend, \ - .msgq = &_name##_msgq, \ - .log_output = &_name##_log_output, \ - .control_block = &_name##_control_block, \ - .timeout = _timeout \ +#define Z_SHELL_LOG_BACKEND_DEFINE(_name, _buf, _size, _queue_size, _timeout) \ + LOG_BACKEND_DEFINE(_name##_backend, log_backend_shell_api, false); \ + K_MSGQ_DEFINE(_name##_msgq, sizeof(struct shell_log_backend_msg), \ + _queue_size, sizeof(void *)); \ + LOG_OUTPUT_DEFINE(_name##_log_output, z_shell_log_backend_output_func, \ + _buf, _size); \ + static struct shell_log_backend_control_block _name##_control_block; \ + static const struct shell_log_backend _name##_log_backend = { \ + .backend = &_name##_backend, \ + .msgq = &_name##_msgq, \ + .log_output = &_name##_log_output, \ + .control_block = &_name##_control_block, \ + .timeout = _timeout \ } -#define SHELL_LOG_BACKEND_PTR(_name) (&_name##_log_backend) +#define Z_SHELL_LOG_BACKEND_PTR(_name) (&_name##_log_backend) #else /* CONFIG_LOG */ -#define SHELL_LOG_BACKEND_DEFINE(_name, _buf, _size, _queue_size, _timeout) -#define SHELL_LOG_BACKEND_PTR(_name) NULL +#define Z_SHELL_LOG_BACKEND_DEFINE(_name, _buf, _size, _queue_size, _timeout) +#define Z_SHELL_LOG_BACKEND_PTR(_name) NULL #endif /* CONFIG_LOG */ /** @brief Enable shell log backend. @@ -92,14 +92,14 @@ int shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx); * @param ctx Pointer to shell instance. * @param init_log_level Initial log level set to all logging sources. */ -void shell_log_backend_enable(const struct shell_log_backend *backend, - void *ctx, uint32_t init_log_level); +void z_shell_log_backend_enable(const struct shell_log_backend *backend, + void *ctx, uint32_t init_log_level); /** @brief Disable shell log backend. * * @param backend Shell log backend instance. */ -void shell_log_backend_disable(const struct shell_log_backend *backend); +void z_shell_log_backend_disable(const struct shell_log_backend *backend); /** @brief Trigger processing of one log entry. * @@ -107,7 +107,7 @@ void shell_log_backend_disable(const struct shell_log_backend *backend); * * @return True if message was processed, false if FIFO was empty */ -bool shell_log_backend_process(const struct shell_log_backend *backend); +bool z_shell_log_backend_process(const struct shell_log_backend *backend); #ifdef __cplusplus } diff --git a/subsys/shell/shell.c b/subsys/shell/shell.c index 8fdfc9747c9..8312350f239 100644 --- a/subsys/shell/shell.c +++ b/subsys/shell/shell.c @@ -1114,7 +1114,8 @@ static void shell_log_process(const struct shell *shell) if (!IS_ENABLED(CONFIG_LOG_IMMEDIATE)) { shell_cmd_line_erase(shell); - processed = shell_log_backend_process(shell->log_backend); + processed = z_shell_log_backend_process( + shell->log_backend); } struct k_poll_signal *signal = @@ -1193,7 +1194,7 @@ static int instance_uninit(const struct shell *shell) if (IS_ENABLED(CONFIG_SHELL_LOG_BACKEND)) { /* todo purge log queue */ - shell_log_backend_disable(shell->log_backend); + z_shell_log_backend_disable(shell->log_backend); } err = shell->iface->api->uninit(shell->iface); @@ -1245,8 +1246,8 @@ void shell_thread(void *shell_handle, void *arg_log_backend, } if (log_backend && IS_ENABLED(CONFIG_SHELL_LOG_BACKEND)) { - shell_log_backend_enable(shell->log_backend, (void *)shell, - log_level); + z_shell_log_backend_enable(shell->log_backend, (void *)shell, + log_level); } /* Enable shell and print prompt. */ diff --git a/subsys/shell/shell_log_backend.c b/subsys/shell/shell_log_backend.c index 2380e5dcdf8..2d0d74c1dea 100644 --- a/subsys/shell/shell_log_backend.c +++ b/subsys/shell/shell_log_backend.c @@ -9,14 +9,14 @@ #include "shell_ops.h" #include -int shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx) +int z_shell_log_backend_output_func(uint8_t *data, size_t length, void *ctx) { z_shell_print_stream(ctx, data, length); return length; } -void shell_log_backend_enable(const struct shell_log_backend *backend, - void *ctx, uint32_t init_log_level) +void z_shell_log_backend_enable(const struct shell_log_backend *backend, + void *ctx, uint32_t init_log_level) { int err = 0; @@ -117,7 +117,7 @@ static void msg_to_fifo(const struct shell *shell, } } -void shell_log_backend_disable(const struct shell_log_backend *backend) +void z_shell_log_backend_disable(const struct shell_log_backend *backend) { fifo_flush(backend); log_backend_disable(backend->backend); @@ -139,7 +139,7 @@ static void msg_process(const struct log_output *log_output, log_msg_put(msg); } -bool shell_log_backend_process(const struct shell_log_backend *backend) +bool z_shell_log_backend_process(const struct shell_log_backend *backend) { uint32_t dropped; const struct shell *shell = @@ -281,11 +281,11 @@ static void panic(const struct log_backend *const backend) shell_op_cursor_horiz_move(shell, -shell->ctx->vt100_ctx.cons.cur_x); - while (shell_log_backend_process(shell->log_backend)) { + while (z_shell_log_backend_process(shell->log_backend)) { /* empty */ } } else { - shell_log_backend_disable(shell->log_backend); + z_shell_log_backend_disable(shell->log_backend); } }