soft_uart: add osmo_soft_uart_free()

Change-Id: I2fdcf6116144d8f16cf4167c37cfa7215d16337f
Related: OS#4396
This commit is contained in:
Vadim Yanitskiy 2023-11-12 17:21:31 +07:00
parent dc023cfc2e
commit 877cfed3b2
3 changed files with 16 additions and 0 deletions

View File

@ -75,6 +75,7 @@ struct osmo_soft_uart_cfg {
struct osmo_soft_uart;
struct osmo_soft_uart *osmo_soft_uart_alloc(void *ctx, const char *name);
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);
int osmo_soft_uart_enable(struct osmo_soft_uart *suart, bool rx, bool tx);

View File

@ -440,6 +440,7 @@ osmo_sock_set_priority;
osmo_sock_unix_init;
osmo_sock_unix_init_ofd;
osmo_soft_uart_alloc;
osmo_soft_uart_free;
osmo_soft_uart_configure;
osmo_soft_uart_enable;
osmo_soft_uart_rx_ubits;

View File

@ -220,6 +220,20 @@ struct osmo_soft_uart *osmo_soft_uart_alloc(void *ctx, const char *name)
return suart;
}
/*! Release memory taken by the given soft-UART.
* \param[in] suart soft-UART instance to be free()d. */
void osmo_soft_uart_free(struct osmo_soft_uart *suart)
{
if (suart == NULL)
return;
osmo_timer_del(&suart->rx.timer);
msgb_free(suart->rx.msg);
talloc_free((void *)suart->name);
talloc_free(suart);
}
/*! change soft-UART configuration to user-provided config */
int osmo_soft_uart_configure(struct osmo_soft_uart *suart, const struct osmo_soft_uart_cfg *cfg)
{