Browse Source

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 <seppo.takalo@nordicsemi.no>
pull/87587/head
Seppo Takalo 4 months ago committed by Benjamin Cabé
parent
commit
15b0f9033b
  1. 6
      subsys/modem/modem_cmux.c

6
subsys/modem/modem_cmux.c

@ -359,15 +359,15 @@ static int16_t modem_cmux_transmit_data_frame(struct modem_cmux *cmux, @@ -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);

Loading…
Cancel
Save