soft_uart: add osmo_soft_uart_free()
Change-Id: I2fdcf6116144d8f16cf4167c37cfa7215d16337f
Related: OS#4396
diff --git a/src/core/libosmocore.map b/src/core/libosmocore.map
index c08d3ff..142e4c4 100644
--- a/src/core/libosmocore.map
+++ b/src/core/libosmocore.map
@@ -440,6 +440,7 @@
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;
diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c
index 22292af..7860453 100644
--- a/src/core/soft_uart.c
+++ b/src/core/soft_uart.c
@@ -220,6 +220,20 @@
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)
{