@@ -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}
@@ -1244,8 +1244,8 @@ static void modem_cmux_drop_frame(struct modem_cmux *cmux)
12441244#if defined(CONFIG_MODEM_CMUX_LOG_LEVEL_DBG )
12451245 struct modem_cmux_frame * frame = & cmux -> frame ;
12461246
1247- frame -> data = cmux -> receive_buf ;
1248- modem_cmux_log_frame (frame , "dropped" , MIN (frame -> data_len , cmux -> receive_buf_size ));
1247+ frame -> data = cmux -> config . receive_buf ;
1248+ modem_cmux_log_frame (frame , "dropped" , MIN (frame -> data_len , cmux -> config . receive_buf_size ));
12491249#endif
12501250}
12511251
@@ -1369,9 +1369,9 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
13691369 break ;
13701370 }
13711371
1372- if (cmux -> frame .data_len > cmux -> receive_buf_size ) {
1372+ if (cmux -> frame .data_len > cmux -> config . receive_buf_size ) {
13731373 LOG_ERR ("Indicated frame data length %u exceeds receive buffer size %u" ,
1374- cmux -> frame .data_len , cmux -> receive_buf_size );
1374+ cmux -> frame .data_len , cmux -> config . receive_buf_size );
13751375
13761376 modem_cmux_drop_frame (cmux );
13771377 break ;
@@ -1383,8 +1383,8 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
13831383
13841384 case MODEM_CMUX_RECEIVE_STATE_DATA :
13851385 /* Copy byte to data */
1386- if (cmux -> receive_buf_len < cmux -> receive_buf_size ) {
1387- cmux -> receive_buf [cmux -> receive_buf_len ] = byte ;
1386+ if (cmux -> receive_buf_len < cmux -> config . receive_buf_size ) {
1387+ cmux -> config . receive_buf [cmux -> receive_buf_len ] = byte ;
13881388 }
13891389 cmux -> receive_buf_len ++ ;
13901390
@@ -1397,9 +1397,9 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
13971397 break ;
13981398
13991399 case MODEM_CMUX_RECEIVE_STATE_FCS :
1400- if (cmux -> receive_buf_len > cmux -> receive_buf_size ) {
1401- LOG_WRN ("Receive buffer overrun (%u > %u)" ,
1402- cmux -> receive_buf_len , cmux -> receive_buf_size );
1400+ if (cmux -> receive_buf_len > cmux -> config . receive_buf_size ) {
1401+ LOG_WRN ("Receive buffer overrun (%u > %u)" , cmux -> receive_buf_len ,
1402+ cmux -> config . receive_buf_size );
14031403 modem_cmux_drop_frame (cmux );
14041404 break ;
14051405 }
@@ -1433,7 +1433,7 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
14331433 }
14341434
14351435 /* Process frame */
1436- cmux -> frame .data = cmux -> receive_buf ;
1436+ cmux -> frame .data = cmux -> config . receive_buf ;
14371437 modem_cmux_on_frame (cmux );
14381438
14391439 /* Await start of next frame */
@@ -1483,7 +1483,7 @@ static void modem_cmux_runtime_pm_handler(struct k_work *item)
14831483 struct k_work_delayable * dwork = k_work_delayable_from_work (item );
14841484 struct modem_cmux * cmux = CONTAINER_OF (dwork , struct modem_cmux , runtime_pm_work );
14851485
1486- if (!cmux -> enable_runtime_power_management ) {
1486+ if (!cmux -> config . enable_runtime_power_management ) {
14871487 return ;
14881488 }
14891489
@@ -1510,12 +1510,12 @@ static void modem_cmux_runtime_pm_handler(struct k_work *item)
15101510
15111511static void runtime_pm_keepalive (struct modem_cmux * cmux )
15121512{
1513- if (cmux == NULL || !cmux -> enable_runtime_power_management ) {
1513+ if (cmux == NULL || !cmux -> config . enable_runtime_power_management ) {
15141514 return ;
15151515 }
15161516
1517- cmux -> idle_timepoint = sys_timepoint_calc (cmux -> idle_timeout );
1518- k_work_reschedule (& cmux -> runtime_pm_work , cmux -> idle_timeout );
1517+ cmux -> idle_timepoint = sys_timepoint_calc (cmux -> config . idle_timeout );
1518+ k_work_reschedule (& cmux -> runtime_pm_work , cmux -> config . idle_timeout );
15191519}
15201520
15211521/** Transmit bytes bypassing the CMUX buffers.
@@ -1540,7 +1540,7 @@ static bool powersave_wait_wakeup(struct modem_cmux *cmux)
15401540 LOG_DBG ("Power saving mode, wake up first" );
15411541 set_state (cmux , MODEM_CMUX_STATE_WAKEUP );
15421542
1543- if (cmux -> close_pipe_on_power_save ) {
1543+ if (cmux -> config . close_pipe_on_power_save ) {
15441544 ret = modem_pipe_open (cmux -> pipe , K_FOREVER );
15451545 if (ret < 0 ) {
15461546 LOG_ERR ("Failed to open pipe for wake up (%d)" , ret );
@@ -1629,7 +1629,7 @@ static void modem_cmux_transmit_handler(struct k_work *item)
16291629 if (cmux -> state == MODEM_CMUX_STATE_CONFIRM_POWERSAVE ) {
16301630 set_state (cmux , MODEM_CMUX_STATE_POWERSAVE );
16311631 LOG_DBG ("Entered power saving mode" );
1632- if (cmux -> close_pipe_on_power_save ) {
1632+ if (cmux -> config . close_pipe_on_power_save ) {
16331633 modem_pipe_close_async (cmux -> pipe );
16341634 }
16351635 }
@@ -1934,18 +1934,13 @@ void modem_cmux_init(struct modem_cmux *cmux, const struct modem_cmux_config *co
19341934 __ASSERT_NO_MSG (config -> transmit_buf != NULL );
19351935 __ASSERT_NO_MSG (config -> transmit_buf_size >= MODEM_CMUX_DATA_FRAME_SIZE_MAX );
19361936
1937- memset (cmux , 0x00 , sizeof (* cmux ));
1938- cmux -> callback = config -> callback ;
1939- cmux -> user_data = config -> user_data ;
1940- cmux -> receive_buf = config -> receive_buf ;
1941- cmux -> receive_buf_size = config -> receive_buf_size ;
1942- cmux -> t3_timepoint = sys_timepoint_calc (K_NO_WAIT );
1943- cmux -> enable_runtime_power_management = config -> enable_runtime_power_management ;
1944- cmux -> close_pipe_on_power_save = config -> close_pipe_on_power_save ;
1945- cmux -> idle_timeout =
1946- cmux -> enable_runtime_power_management ? config -> idle_timeout : K_FOREVER ;
1937+ * cmux = (struct modem_cmux ){
1938+ .t3_timepoint = sys_timepoint_calc (K_NO_WAIT ),
1939+ .config = * config ,
1940+ };
19471941 sys_slist_init (& cmux -> dlcis );
1948- ring_buf_init (& cmux -> transmit_rb , config -> transmit_buf_size , config -> transmit_buf );
1942+ ring_buf_init (& cmux -> transmit_rb , cmux -> config .transmit_buf_size ,
1943+ cmux -> config .transmit_buf );
19491944 k_mutex_init (& cmux -> transmit_rb_lock );
19501945 k_work_init_delayable (& cmux -> receive_work , modem_cmux_receive_handler );
19511946 k_work_init_delayable (& cmux -> transmit_work , modem_cmux_transmit_handler );
0 commit comments