@@ -400,7 +400,7 @@ static uint32_t modem_cmux_get_receive_buf_length(struct modem_cmux *cmux)
400400
401401static uint32_t modem_cmux_get_receive_buf_size (struct modem_cmux * cmux )
402402{
403- return cmux -> receive_buf_size ;
403+ return cmux -> config . receive_buf_size ;
404404}
405405
406406static uint32_t modem_cmux_get_transmit_buf_length (struct modem_cmux * cmux )
@@ -483,11 +483,11 @@ static void modem_cmux_log_received_command(const struct modem_cmux_command *com
483483
484484static void modem_cmux_raise_event (struct modem_cmux * cmux , enum modem_cmux_event event )
485485{
486- if (cmux -> callback == NULL ) {
486+ if (cmux -> config . callback == NULL ) {
487487 return ;
488488 }
489489
490- cmux -> callback (cmux , event , cmux -> user_data );
490+ cmux -> config . callback (cmux , event , cmux -> config . user_data );
491491}
492492
493493static void modem_cmux_bus_callback (struct modem_pipe * pipe , enum modem_pipe_event event ,
@@ -506,7 +506,7 @@ static void modem_cmux_bus_callback(struct modem_pipe *pipe, enum modem_pipe_eve
506506 break ;
507507 case MODEM_PIPE_EVENT_TRANSMIT_IDLE :
508508 /* If we keep UART open in power-save, we should avoid waking up on RX idle */
509- if (!cmux -> close_pipe_on_power_save && is_powersaving (cmux )) {
509+ if (!cmux -> config . close_pipe_on_power_save && is_powersaving (cmux )) {
510510 break ;
511511 }
512512 modem_work_schedule (& cmux -> transmit_work , K_NO_WAIT );
@@ -896,7 +896,7 @@ static void modem_cmux_on_psc_response(struct modem_cmux *cmux)
896896 set_state (cmux , MODEM_CMUX_STATE_POWERSAVE );
897897 k_mutex_unlock (& cmux -> transmit_rb_lock );
898898
899- if (cmux -> close_pipe_on_power_save ) {
899+ if (cmux -> config . close_pipe_on_power_save ) {
900900 modem_pipe_close_async (cmux -> pipe );
901901 }
902902}
@@ -1249,8 +1249,8 @@ static void modem_cmux_drop_frame(struct modem_cmux *cmux)
12491249#if defined(CONFIG_MODEM_CMUX_LOG_LEVEL_DBG )
12501250 struct modem_cmux_frame * frame = & cmux -> frame ;
12511251
1252- frame -> data = cmux -> receive_buf ;
1253- modem_cmux_log_frame (frame , "dropped" , MIN (frame -> data_len , cmux -> receive_buf_size ));
1252+ frame -> data = cmux -> config . receive_buf ;
1253+ modem_cmux_log_frame (frame , "dropped" , MIN (frame -> data_len , cmux -> config . receive_buf_size ));
12541254#endif
12551255}
12561256
@@ -1374,9 +1374,9 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
13741374 break ;
13751375 }
13761376
1377- if (cmux -> frame .data_len > cmux -> receive_buf_size ) {
1377+ if (cmux -> frame .data_len > cmux -> config . receive_buf_size ) {
13781378 LOG_ERR ("Indicated frame data length %u exceeds receive buffer size %u" ,
1379- cmux -> frame .data_len , cmux -> receive_buf_size );
1379+ cmux -> frame .data_len , cmux -> config . receive_buf_size );
13801380
13811381 modem_cmux_drop_frame (cmux );
13821382 break ;
@@ -1388,8 +1388,8 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
13881388
13891389 case MODEM_CMUX_RECEIVE_STATE_DATA :
13901390 /* Copy byte to data */
1391- if (cmux -> receive_buf_len < cmux -> receive_buf_size ) {
1392- cmux -> receive_buf [cmux -> receive_buf_len ] = byte ;
1391+ if (cmux -> receive_buf_len < cmux -> config . receive_buf_size ) {
1392+ cmux -> config . receive_buf [cmux -> receive_buf_len ] = byte ;
13931393 }
13941394 cmux -> receive_buf_len ++ ;
13951395
@@ -1402,9 +1402,9 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
14021402 break ;
14031403
14041404 case MODEM_CMUX_RECEIVE_STATE_FCS :
1405- if (cmux -> receive_buf_len > cmux -> receive_buf_size ) {
1406- LOG_WRN ("Receive buffer overrun (%u > %u)" ,
1407- cmux -> receive_buf_len , cmux -> receive_buf_size );
1405+ if (cmux -> receive_buf_len > cmux -> config . receive_buf_size ) {
1406+ LOG_WRN ("Receive buffer overrun (%u > %u)" , cmux -> receive_buf_len ,
1407+ cmux -> config . receive_buf_size );
14081408 modem_cmux_drop_frame (cmux );
14091409 break ;
14101410 }
@@ -1438,7 +1438,7 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
14381438 }
14391439
14401440 /* Process frame */
1441- cmux -> frame .data = cmux -> receive_buf ;
1441+ cmux -> frame .data = cmux -> config . receive_buf ;
14421442 modem_cmux_on_frame (cmux );
14431443
14441444 /* Await start of next frame */
@@ -1488,7 +1488,7 @@ static void modem_cmux_runtime_pm_handler(struct k_work *item)
14881488 struct k_work_delayable * dwork = k_work_delayable_from_work (item );
14891489 struct modem_cmux * cmux = CONTAINER_OF (dwork , struct modem_cmux , runtime_pm_work );
14901490
1491- if (!cmux -> enable_runtime_power_management ) {
1491+ if (!cmux -> config . enable_runtime_power_management ) {
14921492 return ;
14931493 }
14941494
@@ -1515,12 +1515,12 @@ static void modem_cmux_runtime_pm_handler(struct k_work *item)
15151515
15161516static void runtime_pm_keepalive (struct modem_cmux * cmux )
15171517{
1518- if (cmux == NULL || !cmux -> enable_runtime_power_management ) {
1518+ if (cmux == NULL || !cmux -> config . enable_runtime_power_management ) {
15191519 return ;
15201520 }
15211521
1522- cmux -> idle_timepoint = sys_timepoint_calc (cmux -> idle_timeout );
1523- k_work_reschedule (& cmux -> runtime_pm_work , cmux -> idle_timeout );
1522+ cmux -> idle_timepoint = sys_timepoint_calc (cmux -> config . idle_timeout );
1523+ k_work_reschedule (& cmux -> runtime_pm_work , cmux -> config . idle_timeout );
15241524}
15251525
15261526/** Transmit bytes bypassing the CMUX buffers.
@@ -1545,7 +1545,7 @@ static bool powersave_wait_wakeup(struct modem_cmux *cmux)
15451545 LOG_DBG ("Power saving mode, wake up first" );
15461546 set_state (cmux , MODEM_CMUX_STATE_WAKEUP );
15471547
1548- if (cmux -> close_pipe_on_power_save ) {
1548+ if (cmux -> config . close_pipe_on_power_save ) {
15491549 ret = modem_pipe_open (cmux -> pipe , K_FOREVER );
15501550 if (ret < 0 ) {
15511551 LOG_ERR ("Failed to open pipe for wake up (%d)" , ret );
@@ -1634,7 +1634,7 @@ static void modem_cmux_transmit_handler(struct k_work *item)
16341634 if (cmux -> state == MODEM_CMUX_STATE_CONFIRM_POWERSAVE ) {
16351635 set_state (cmux , MODEM_CMUX_STATE_POWERSAVE );
16361636 LOG_DBG ("Entered power saving mode" );
1637- if (cmux -> close_pipe_on_power_save ) {
1637+ if (cmux -> config . close_pipe_on_power_save ) {
16381638 modem_pipe_close_async (cmux -> pipe );
16391639 }
16401640 }
@@ -1940,18 +1940,13 @@ void modem_cmux_init(struct modem_cmux *cmux, const struct modem_cmux_config *co
19401940 __ASSERT_NO_MSG (config -> transmit_buf != NULL );
19411941 __ASSERT_NO_MSG (config -> transmit_buf_size >= MODEM_CMUX_DATA_FRAME_SIZE_MAX );
19421942
1943- memset (cmux , 0x00 , sizeof (* cmux ));
1944- cmux -> callback = config -> callback ;
1945- cmux -> user_data = config -> user_data ;
1946- cmux -> receive_buf = config -> receive_buf ;
1947- cmux -> receive_buf_size = config -> receive_buf_size ;
1948- cmux -> t3_timepoint = sys_timepoint_calc (K_NO_WAIT );
1949- cmux -> enable_runtime_power_management = config -> enable_runtime_power_management ;
1950- cmux -> close_pipe_on_power_save = config -> close_pipe_on_power_save ;
1951- cmux -> idle_timeout =
1952- cmux -> enable_runtime_power_management ? config -> idle_timeout : K_FOREVER ;
1943+ * cmux = (struct modem_cmux ){
1944+ .t3_timepoint = sys_timepoint_calc (K_NO_WAIT ),
1945+ .config = * config ,
1946+ };
19531947 sys_slist_init (& cmux -> dlcis );
1954- ring_buf_init (& cmux -> transmit_rb , config -> transmit_buf_size , config -> transmit_buf );
1948+ ring_buf_init (& cmux -> transmit_rb , cmux -> config .transmit_buf_size ,
1949+ cmux -> config .transmit_buf );
19551950 k_mutex_init (& cmux -> transmit_rb_lock );
19561951 k_work_init_delayable (& cmux -> receive_work , modem_cmux_receive_handler );
19571952 k_work_init_delayable (& cmux -> transmit_work , modem_cmux_transmit_handler );
0 commit comments