Skip to content

Commit

Permalink
modem: cmux: apply static const to reduce RAM usage
Browse files Browse the repository at this point in the history
Added `static const` to various `struct modem_pipe_api` and
`frame` in `modem_cmux_connect_handler` to make these structures
immutable and reduce RAM usage.

Corrected a typo, changing "consequtive" to "consecutive".

Signed-off-by: Pisit Sawangvonganan <pisit@ndrsolution.com>
  • Loading branch information
ndrs-pst authored and nashif committed Jul 27, 2024
1 parent ba30e7b commit c43b20e
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion subsys/modem/backends/modem_backend_tty.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ static int modem_backend_tty_close(void *data)
return 0;
}

struct modem_pipe_api modem_backend_tty_api = {
static const struct modem_pipe_api modem_backend_tty_api = {
.open = modem_backend_tty_open,
.transmit = modem_backend_tty_transmit,
.receive = modem_backend_tty_receive,
Expand Down
2 changes: 1 addition & 1 deletion subsys/modem/backends/modem_backend_uart_async.c
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ static int modem_backend_uart_async_close(void *data)
return 0;
}

struct modem_pipe_api modem_backend_uart_async_api = {
static const struct modem_pipe_api modem_backend_uart_async_api = {
.open = modem_backend_uart_async_open,
.transmit = modem_backend_uart_async_transmit,
.receive = modem_backend_uart_async_receive,
Expand Down
2 changes: 1 addition & 1 deletion subsys/modem/backends/modem_backend_uart_isr.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static int modem_backend_uart_isr_close(void *data)
return 0;
}

struct modem_pipe_api modem_backend_uart_isr_api = {
static const struct modem_pipe_api modem_backend_uart_isr_api = {
.open = modem_backend_uart_isr_open,
.transmit = modem_backend_uart_isr_transmit,
.receive = modem_backend_uart_isr_receive,
Expand Down
6 changes: 3 additions & 3 deletions subsys/modem/modem_cmux.c
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by

case MODEM_CMUX_RECEIVE_STATE_RESYNC:
/*
* Allow any number of consequtive flags (0xF9).
* Allow any number of consecutive flags (0xF9).
* 0xF9 could also be a valid address field for DLCI 62.
*/
if (byte == 0xF9) {
Expand Down Expand Up @@ -992,7 +992,7 @@ static void modem_cmux_connect_handler(struct k_work *item)

cmux->state = MODEM_CMUX_STATE_CONNECTING;

struct modem_cmux_frame frame = {
static const struct modem_cmux_frame frame = {
.dlci_address = 0,
.cr = true,
.pf = true,
Expand Down Expand Up @@ -1154,7 +1154,7 @@ static int modem_cmux_dlci_pipe_api_close(void *data)
return ret;
}

struct modem_pipe_api modem_cmux_dlci_pipe_api = {
static const struct modem_pipe_api modem_cmux_dlci_pipe_api = {
.open = modem_cmux_dlci_pipe_api_open,
.transmit = modem_cmux_dlci_pipe_api_transmit,
.receive = modem_cmux_dlci_pipe_api_receive,
Expand Down

0 comments on commit c43b20e

Please sign in to comment.