From 15b0f9033b3e5f820547fa291d72c23304aa0c7c Mon Sep 17 00:00:00 2001 From: Seppo Takalo Date: Tue, 18 Mar 2025 16:39:59 +0200 Subject: [PATCH] modem: cmux: Do not return error on low buffer space If we end up writing zero bytes to cmux output, we can return zero instead of -ENOMEM as it would break various modules when using small buffers. For example modem_chat.c does not tolerate -ENOMEM but handles zero OK. Signed-off-by: Seppo Takalo --- subsys/modem/modem_cmux.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/subsys/modem/modem_cmux.c b/subsys/modem/modem_cmux.c index 74542aeda66..48498f5b72c 100644 --- a/subsys/modem/modem_cmux.c +++ b/subsys/modem/modem_cmux.c @@ -359,15 +359,15 @@ static int16_t modem_cmux_transmit_data_frame(struct modem_cmux *cmux, space = ring_buf_space_get(&cmux->transmit_rb); /* - * Two command frames are reserved for command channel, and we shall prefer + * One command frame is reserved for command channel, and we shall prefer * waiting for more than MODEM_CMUX_DATA_FRAME_SIZE_MIN bytes available in the * transmit buffer rather than transmitting a few bytes at a time. This avoids * excessive wrapping overhead, since transmitting a single byte will require 8 * bytes of wrapping. */ - if (space < ((MODEM_CMUX_CMD_FRAME_SIZE_MAX * 2) + MODEM_CMUX_DATA_FRAME_SIZE_MIN)) { + if (space < (MODEM_CMUX_CMD_FRAME_SIZE_MAX + MODEM_CMUX_DATA_FRAME_SIZE_MIN)) { k_mutex_unlock(&cmux->transmit_rb_lock); - return -ENOMEM; + return 0; } modem_cmux_log_transmit_frame(frame);