aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVadim Yanitskiy <vyanitskiy@sysmocom.de>2023-12-04 03:17:26 +0700
committerVadim Yanitskiy <vyanitskiy@sysmocom.de>2023-12-04 03:17:34 +0700
commitffb8d5e026a8e0a014ef0357fbfb8c03a40f89c2 (patch)
tree7564d7bef42d0e8eb89fceb8fd8351c15fd95d3c
parent275c86e7ee8961fa7aaf4c27cbd4c39c96961cd3 (diff)
soft_uart: osmo_soft_uart_tx_ubits(): return number of bits pulled
This is a partial revert of 0887188c6b133b69142965d65e1be8a0696a6272. We actually want to return number of bits pulled, because in the upcoming commit implementing the flow control we want to be able to signal to the caller that the buffer was not completely filled, but only partly. Change-Id: I47a56f0fc36f2bc8f5a797d7fec64dfb56842388 Related: OS#4396
-rw-r--r--src/core/soft_uart.c4
-rw-r--r--tests/soft_uart/soft_uart_test.c4
2 files changed, 4 insertions, 4 deletions
diff --git a/src/core/soft_uart.c b/src/core/soft_uart.c
index a1888d68..57502828 100644
--- a/src/core/soft_uart.c
+++ b/src/core/soft_uart.c
@@ -277,7 +277,7 @@ static inline ubit_t suart_tx_bit(struct osmo_soft_uart *suart, struct msgb *msg
* \param[in] suart soft-UART instance to pull the bits from.
* \param[out] ubits pointer to a buffer where to store pulled bits.
* \param[in] n_ubits number of unpacked bits to be pulled.
- * \returns 0 on success; negative on error.
+ * \returns number of bits pulled; negative on error.
* -EAGAIN indicates that the transmitter is disabled. */
int osmo_soft_uart_tx_ubits(struct osmo_soft_uart *suart, ubit_t *ubits, size_t n_ubits)
{
@@ -318,7 +318,7 @@ int osmo_soft_uart_tx_ubits(struct osmo_soft_uart *suart, ubit_t *ubits, size_t
ubits[i] = suart_tx_bit(suart, msg);
msgb_free(msg);
- return 0;
+ return n_ubits;
}
/*! Set the modem status lines of the given soft-UART.
diff --git a/tests/soft_uart/soft_uart_test.c b/tests/soft_uart/soft_uart_test.c
index 276ffe11..ef648550 100644
--- a/tests/soft_uart/soft_uart_test.c
+++ b/tests/soft_uart/soft_uart_test.c
@@ -217,7 +217,7 @@ static void test_tx_rx_exec_one(struct osmo_soft_uart *suart,
int rc;
rc = osmo_soft_uart_tx_ubits(suart, &tx_buf[0], n_bits_total);
- OSMO_ASSERT(rc == 0);
+ OSMO_ASSERT(rc == n_bits_total);
rc = osmo_soft_uart_rx_ubits(suart, &tx_buf[0], n_bits_total);
OSMO_ASSERT(rc == 0);
@@ -332,7 +332,7 @@ static void test_tx_rx_pull_n(unsigned int n)
printf("======== %s(): pulling %lu bits (%u at a time)\n", __func__, sizeof(tx_buf), n);
for (unsigned int i = 0; i < sizeof(tx_buf); i += n) {
rc = osmo_soft_uart_tx_ubits(suart, &tx_buf[i], n);
- OSMO_ASSERT(rc == 0);
+ OSMO_ASSERT(rc == n);
}
printf("%s\n", osmo_ubit_dump(&tx_buf[0], sizeof(tx_buf)));