From 59afb8f14ce77b681f34cade2a58f16dd1a048d4 Mon Sep 17 00:00:00 2001 From: Vadim Yanitskiy Date: Wed, 29 Nov 2023 23:58:10 +0700 Subject: [PATCH] soft_uart: add osmo_soft_uart_{get,set}_name() Change-Id: Iabf29f42d876035481011fa8e8a51c0590fe63b8 Related: OS#4396 --- include/osmocom/core/soft_uart.h | 4 ++++ src/core/libosmocore.map | 2 ++ src/core/soft_uart.c | 16 ++++++++++++++++ 3 files changed, 22 insertions(+) diff --git a/include/osmocom/core/soft_uart.h b/include/osmocom/core/soft_uart.h index 097d2eed3..7b7c39480 100644 --- a/include/osmocom/core/soft_uart.h +++ b/include/osmocom/core/soft_uart.h @@ -87,6 +87,10 @@ struct osmo_soft_uart *osmo_soft_uart_alloc(void *ctx, const char *name, const struct osmo_soft_uart_cfg *cfg); void osmo_soft_uart_free(struct osmo_soft_uart *suart); int osmo_soft_uart_configure(struct osmo_soft_uart *suart, const struct osmo_soft_uart_cfg *cfg); + +const char *osmo_soft_uart_get_name(const struct osmo_soft_uart *suart); +void osmo_soft_uart_set_name(struct osmo_soft_uart *suart, const char *name); + int osmo_soft_uart_set_rx(struct osmo_soft_uart *suart, bool enable); int osmo_soft_uart_set_tx(struct osmo_soft_uart *suart, bool enable); diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map index 3d6aa424d..4ae51085b 100644 --- a/src/core/libosmocore.map +++ b/src/core/libosmocore.map @@ -444,6 +444,8 @@ osmo_soft_uart_default_cfg; osmo_soft_uart_alloc; osmo_soft_uart_free; osmo_soft_uart_configure; +osmo_soft_uart_get_name; +osmo_soft_uart_set_name; osmo_soft_uart_set_rx; osmo_soft_uart_set_tx; osmo_soft_uart_rx_ubits; diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c index 4fffaeee6..5ddddb45a 100644 --- a/src/core/soft_uart.c +++ b/src/core/soft_uart.c @@ -396,6 +396,22 @@ int osmo_soft_uart_configure(struct osmo_soft_uart *suart, const struct osmo_sof return 0; } +/*! Get a name for the given soft-UART instance. + * \param[in] suart soft-UART instance to get the name from. + * \returns name of the given soft-UART instance. */ +const char *osmo_soft_uart_get_name(const struct osmo_soft_uart *suart) +{ + return suart->name; +} + +/*! Set a new name for the given soft-UART instance. + * \param[in] suart soft-UART instance to set the name for. + * \param[in] name the new name. */ +void osmo_soft_uart_set_name(struct osmo_soft_uart *suart, const char *name) +{ + osmo_talloc_replace_string(suart, (char **)&suart->name, name); +} + /*! Enable/disable receiver of the given soft-UART. * \param[in] suart soft-UART instance to be re-configured. * \param[in] enable enable/disable state of the receiver.