laforge has submitted this change. (
https://gerrit.osmocom.org/c/libosmocore/+/35018?usp=email )
Change subject: soft_uart: add osmo_soft_uart_free()
......................................................................
soft_uart: add osmo_soft_uart_free()
Change-Id: I2fdcf6116144d8f16cf4167c37cfa7215d16337f
Related: OS#4396
---
M include/osmocom/core/soft_uart.h
M src/core/libosmocore.map
M src/core/soft_uart.c
3 files changed, 26 insertions(+), 0 deletions(-)
Approvals:
laforge: Looks good to me, approved
jolly: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/include/osmocom/core/soft_uart.h b/include/osmocom/core/soft_uart.h
index 36a43fe..4f9c1fc 100644
--- a/include/osmocom/core/soft_uart.h
+++ b/include/osmocom/core/soft_uart.h
@@ -75,6 +75,7 @@
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);
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)
{
--
To view, visit
https://gerrit.osmocom.org/c/libosmocore/+/35018?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: I2fdcf6116144d8f16cf4167c37cfa7215d16337f
Gerrit-Change-Number: 35018
Gerrit-PatchSet: 3
Gerrit-Owner: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: jolly <andreas(a)eversberg.eu>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-MessageType: merged