Skip to content

Commit aa47b25

Browse files
committed
[nrf fromlist] modem: cmux: Do not return error on low buffer
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. Upstream PR #: 87115 Signed-off-by: Seppo Takalo <[email protected]>
1 parent 3503016 commit aa47b25

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

subsys/modem/modem_cmux.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -359,15 +359,15 @@ static int16_t modem_cmux_transmit_data_frame(struct modem_cmux *cmux,
359359
space = ring_buf_space_get(&cmux->transmit_rb);
360360

361361
/*
362-
* Two command frames are reserved for command channel, and we shall prefer
362+
* One command frame is reserved for command channel, and we shall prefer
363363
* waiting for more than MODEM_CMUX_DATA_FRAME_SIZE_MIN bytes available in the
364364
* transmit buffer rather than transmitting a few bytes at a time. This avoids
365365
* excessive wrapping overhead, since transmitting a single byte will require 8
366366
* bytes of wrapping.
367367
*/
368-
if (space < ((MODEM_CMUX_CMD_FRAME_SIZE_MAX * 2) + MODEM_CMUX_DATA_FRAME_SIZE_MIN)) {
368+
if (space < (MODEM_CMUX_CMD_FRAME_SIZE_MAX + MODEM_CMUX_DATA_FRAME_SIZE_MIN)) {
369369
k_mutex_unlock(&cmux->transmit_rb_lock);
370-
return -ENOMEM;
370+
return 0;
371371
}
372372

373373
modem_cmux_log_transmit_frame(frame);

0 commit comments

Comments
 (0)