From ef2d51c07661356a10c071dc6c24bfe80b6b3cbb Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Thu, 20 Jan 2022 23:22:38 +0800 Subject: [PATCH] drivers: modem: gsm: Remove unnecessary mux_enabled check Remove redundant mux_enabled checks, the code execution will not reach here if mux_enabled is false in the first place. Signed-off-by: Yong Cong Sin --- drivers/modem/gsm_ppp.c | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/drivers/modem/gsm_ppp.c b/drivers/modem/gsm_ppp.c index f7e9ef61cad..3f08f1218c4 100644 --- a/drivers/modem/gsm_ppp.c +++ b/drivers/modem/gsm_ppp.c @@ -612,7 +612,7 @@ static void gsm_finalize_connection(struct gsm_modem *gsm) goto attaching; } - if (IS_ENABLED(CONFIG_GSM_MUX) && gsm->mux_enabled) { + if (IS_ENABLED(CONFIG_GSM_MUX)) { ret = modem_cmd_send_nolock(&gsm->context.iface, &gsm->context.cmd_handler, &response_cmds[0], @@ -736,7 +736,7 @@ attaching: set_ppp_carrier_on(gsm); - if (IS_ENABLED(CONFIG_GSM_MUX) && gsm->mux_enabled) { + if (IS_ENABLED(CONFIG_GSM_MUX)) { /* Re-use the original iface for AT channel */ ret = modem_iface_uart_init_dev(&gsm->context.iface, gsm->at_dev); @@ -941,7 +941,6 @@ static void mux_setup(struct k_work *work) gsm->ppp_dev); if (ret < 0) { LOG_DBG("iface %suart error %d", "PPP ", ret); - gsm->mux_enabled = false; goto fail; } @@ -990,26 +989,22 @@ static void gsm_configure(struct k_work *work) gsm->mux_enabled == false) { ret = mux_enable(gsm); - if (ret == 0) { - LOG_DBG("GSM muxing %s", "enabled"); - gsm->mux_enabled = true; - } else { + if (ret) { LOG_DBG("GSM muxing %s", "disabled"); (void)gsm_work_reschedule(&gsm->gsm_configure_work, K_NO_WAIT); return; } - if (gsm->mux_enabled) { - gsm->state = STATE_INIT; + LOG_DBG("GSM muxing %s", "enabled"); + gsm->mux_enabled = true; - k_work_init_delayable(&gsm->gsm_configure_work, - mux_setup); + gsm->state = STATE_INIT; - (void)gsm_work_reschedule(&gsm->gsm_configure_work, - K_NO_WAIT); - return; - } + k_work_init_delayable(&gsm->gsm_configure_work, mux_setup); + + (void)gsm_work_reschedule(&gsm->gsm_configure_work, K_NO_WAIT); + return; } gsm_finalize_connection(gsm);