@@ -224,7 +224,7 @@ static uint32_t modem_cmux_get_receive_buf_length(struct modem_cmux *cmux)
224224
225225static uint32_t modem_cmux_get_receive_buf_size (struct modem_cmux * cmux )
226226{
227- return cmux -> receive_buf_size ;
227+ return cmux -> config . receive_buf_size ;
228228}
229229
230230static uint32_t modem_cmux_get_transmit_buf_length (struct modem_cmux * cmux )
@@ -307,11 +307,11 @@ static void modem_cmux_log_received_command(const struct modem_cmux_command *com
307307
308308static void modem_cmux_raise_event (struct modem_cmux * cmux , enum modem_cmux_event event )
309309{
310- if (cmux -> callback == NULL ) {
310+ if (cmux -> config . callback == NULL ) {
311311 return ;
312312 }
313313
314- cmux -> callback (cmux , event , cmux -> user_data );
314+ cmux -> config . callback (cmux , event , cmux -> config . user_data );
315315}
316316
317317static void modem_cmux_bus_callback (struct modem_pipe * pipe , enum modem_pipe_event event ,
@@ -330,7 +330,7 @@ static void modem_cmux_bus_callback(struct modem_pipe *pipe, enum modem_pipe_eve
330330 break ;
331331 case MODEM_PIPE_EVENT_TRANSMIT_IDLE :
332332 /* If we keep UART open in power-save, we should avoid waking up on RX idle */
333- if (!cmux -> close_pipe_on_power_save && is_powersaving (cmux )) {
333+ if (!cmux -> config . close_pipe_on_power_save && is_powersaving (cmux )) {
334334 break ;
335335 }
336336 modem_work_schedule (& cmux -> transmit_work , K_NO_WAIT );
@@ -699,7 +699,7 @@ static void modem_cmux_on_psc_response(struct modem_cmux *cmux)
699699 set_state (cmux , MODEM_CMUX_STATE_POWERSAVE );
700700 k_mutex_unlock (& cmux -> transmit_rb_lock );
701701
702- if (cmux -> close_pipe_on_power_save ) {
702+ if (cmux -> config . close_pipe_on_power_save ) {
703703 modem_pipe_close_async (cmux -> pipe );
704704 }
705705}
@@ -1046,8 +1046,8 @@ static void modem_cmux_drop_frame(struct modem_cmux *cmux)
10461046#if defined(CONFIG_MODEM_CMUX_LOG_LEVEL_DBG )
10471047 struct modem_cmux_frame * frame = & cmux -> frame ;
10481048
1049- frame -> data = cmux -> receive_buf ;
1050- modem_cmux_log_frame (frame , "dropped" , MIN (frame -> data_len , cmux -> receive_buf_size ));
1049+ frame -> data = cmux -> config . receive_buf ;
1050+ modem_cmux_log_frame (frame , "dropped" , MIN (frame -> data_len , cmux -> config . receive_buf_size ));
10511051#endif
10521052}
10531053
@@ -1171,9 +1171,9 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
11711171 break ;
11721172 }
11731173
1174- if (cmux -> frame .data_len > cmux -> receive_buf_size ) {
1174+ if (cmux -> frame .data_len > cmux -> config . receive_buf_size ) {
11751175 LOG_ERR ("Indicated frame data length %u exceeds receive buffer size %u" ,
1176- cmux -> frame .data_len , cmux -> receive_buf_size );
1176+ cmux -> frame .data_len , cmux -> config . receive_buf_size );
11771177
11781178 modem_cmux_drop_frame (cmux );
11791179 break ;
@@ -1185,8 +1185,8 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
11851185
11861186 case MODEM_CMUX_RECEIVE_STATE_DATA :
11871187 /* Copy byte to data */
1188- if (cmux -> receive_buf_len < cmux -> receive_buf_size ) {
1189- cmux -> receive_buf [cmux -> receive_buf_len ] = byte ;
1188+ if (cmux -> receive_buf_len < cmux -> config . receive_buf_size ) {
1189+ cmux -> config . receive_buf [cmux -> receive_buf_len ] = byte ;
11901190 }
11911191 cmux -> receive_buf_len ++ ;
11921192
@@ -1199,9 +1199,9 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
11991199 break ;
12001200
12011201 case MODEM_CMUX_RECEIVE_STATE_FCS :
1202- if (cmux -> receive_buf_len > cmux -> receive_buf_size ) {
1203- LOG_WRN ("Receive buffer overrun (%u > %u)" ,
1204- cmux -> receive_buf_len , cmux -> receive_buf_size );
1202+ if (cmux -> receive_buf_len > cmux -> config . receive_buf_size ) {
1203+ LOG_WRN ("Receive buffer overrun (%u > %u)" , cmux -> receive_buf_len ,
1204+ cmux -> config . receive_buf_size );
12051205 modem_cmux_drop_frame (cmux );
12061206 break ;
12071207 }
@@ -1235,7 +1235,7 @@ static void modem_cmux_process_received_byte(struct modem_cmux *cmux, uint8_t by
12351235 }
12361236
12371237 /* Process frame */
1238- cmux -> frame .data = cmux -> receive_buf ;
1238+ cmux -> frame .data = cmux -> config . receive_buf ;
12391239 modem_cmux_on_frame (cmux );
12401240
12411241 /* Await start of next frame */
@@ -1285,7 +1285,7 @@ static void modem_cmux_runtime_pm_handler(struct k_work *item)
12851285 struct k_work_delayable * dwork = k_work_delayable_from_work (item );
12861286 struct modem_cmux * cmux = CONTAINER_OF (dwork , struct modem_cmux , runtime_pm_work );
12871287
1288- if (!cmux -> enable_runtime_power_management ) {
1288+ if (!cmux -> config . enable_runtime_power_management ) {
12891289 return ;
12901290 }
12911291
@@ -1312,12 +1312,12 @@ static void modem_cmux_runtime_pm_handler(struct k_work *item)
13121312
13131313static void runtime_pm_keepalive (struct modem_cmux * cmux )
13141314{
1315- if (cmux == NULL || !cmux -> enable_runtime_power_management ) {
1315+ if (cmux == NULL || !cmux -> config . enable_runtime_power_management ) {
13161316 return ;
13171317 }
13181318
1319- cmux -> idle_timepoint = sys_timepoint_calc (cmux -> idle_timeout );
1320- k_work_reschedule (& cmux -> runtime_pm_work , cmux -> idle_timeout );
1319+ cmux -> idle_timepoint = sys_timepoint_calc (cmux -> config . idle_timeout );
1320+ k_work_reschedule (& cmux -> runtime_pm_work , cmux -> config . idle_timeout );
13211321}
13221322
13231323/** Transmit bytes bypassing the CMUX buffers.
@@ -1342,7 +1342,7 @@ static bool powersave_wait_wakeup(struct modem_cmux *cmux)
13421342 LOG_DBG ("Power saving mode, wake up first" );
13431343 set_state (cmux , MODEM_CMUX_STATE_WAKEUP );
13441344
1345- if (cmux -> close_pipe_on_power_save ) {
1345+ if (cmux -> config . close_pipe_on_power_save ) {
13461346 ret = modem_pipe_open (cmux -> pipe , K_FOREVER );
13471347 if (ret < 0 ) {
13481348 LOG_ERR ("Failed to open pipe for wake up (%d)" , ret );
@@ -1431,7 +1431,7 @@ static void modem_cmux_transmit_handler(struct k_work *item)
14311431 if (cmux -> state == MODEM_CMUX_STATE_CONFIRM_POWERSAVE ) {
14321432 set_state (cmux , MODEM_CMUX_STATE_POWERSAVE );
14331433 LOG_DBG ("Entered power saving mode" );
1434- if (cmux -> close_pipe_on_power_save ) {
1434+ if (cmux -> config . close_pipe_on_power_save ) {
14351435 modem_pipe_close_async (cmux -> pipe );
14361436 }
14371437 }
@@ -1734,18 +1734,13 @@ void modem_cmux_init(struct modem_cmux *cmux, const struct modem_cmux_config *co
17341734 __ASSERT_NO_MSG (config -> transmit_buf != NULL );
17351735 __ASSERT_NO_MSG (config -> transmit_buf_size >= MODEM_CMUX_DATA_FRAME_SIZE_MAX );
17361736
1737- memset (cmux , 0x00 , sizeof (* cmux ));
1738- cmux -> callback = config -> callback ;
1739- cmux -> user_data = config -> user_data ;
1740- cmux -> receive_buf = config -> receive_buf ;
1741- cmux -> receive_buf_size = config -> receive_buf_size ;
1742- cmux -> t3_timepoint = sys_timepoint_calc (K_NO_WAIT );
1743- cmux -> enable_runtime_power_management = config -> enable_runtime_power_management ;
1744- cmux -> close_pipe_on_power_save = config -> close_pipe_on_power_save ;
1745- cmux -> idle_timeout =
1746- cmux -> enable_runtime_power_management ? config -> idle_timeout : K_FOREVER ;
1737+ * cmux = (struct modem_cmux ){
1738+ .t3_timepoint = sys_timepoint_calc (K_NO_WAIT ),
1739+ .config = * config ,
1740+ };
17471741 sys_slist_init (& cmux -> dlcis );
1748- ring_buf_init (& cmux -> transmit_rb , config -> transmit_buf_size , config -> transmit_buf );
1742+ ring_buf_init (& cmux -> transmit_rb , cmux -> config .transmit_buf_size ,
1743+ cmux -> config .transmit_buf );
17491744 k_mutex_init (& cmux -> transmit_rb_lock );
17501745 k_work_init_delayable (& cmux -> receive_work , modem_cmux_receive_handler );
17511746 k_work_init_delayable (& cmux -> transmit_work , modem_cmux_transmit_handler );
0 commit comments