From a5394e865ade73f340668fd44ed7f85c32d4c551 Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Sun, 20 Feb 2022 16:29:54 +0800 Subject: [PATCH] drivers: modem: gsm: Define tx_lock timeout at the top The tx_lock timeout is closely related to GSM_CMD_AT_TIMEOUT & GSM_CMD_SETUP_TIMEOUT, and should be longer than both of them, otherwise the gsm_ppp_stop might fail to lock the tx. Define the timeout at the top of the driver and added a comment to make it clear for the user. Signed-off-by: Yong Cong Sin --- drivers/modem/gsm_ppp.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/modem/gsm_ppp.c b/drivers/modem/gsm_ppp.c index 5ac4a3fb9fe..7093e4678e6 100644 --- a/drivers/modem/gsm_ppp.c +++ b/drivers/modem/gsm_ppp.c @@ -30,6 +30,10 @@ LOG_MODULE_REGISTER(modem_gsm, CONFIG_MODEM_LOG_LEVEL); #define GSM_CMD_READ_BUF 128 #define GSM_CMD_AT_TIMEOUT K_SECONDS(2) #define GSM_CMD_SETUP_TIMEOUT K_SECONDS(6) +/* GSM_CMD_LOCK_TIMEOUT should be longer than GSM_CMD_AT_TIMEOUT & GSM_CMD_SETUP_TIMEOUT, + * otherwise the gsm_ppp_stop might fail to lock tx. + */ +#define GSM_CMD_LOCK_TIMEOUT K_SECONDS(10) #define GSM_RX_STACK_SIZE CONFIG_MODEM_GSM_RX_STACK_SIZE #define GSM_WORKQ_STACK_SIZE CONFIG_MODEM_GSM_WORKQ_STACK_SIZE #define GSM_RECV_MAX_BUF 30 @@ -1054,8 +1058,7 @@ void gsm_ppp_stop(const struct device *dev) } } - if (modem_cmd_handler_tx_lock(&gsm->context.cmd_handler, - K_SECONDS(10))) { + if (modem_cmd_handler_tx_lock(&gsm->context.cmd_handler, GSM_CMD_LOCK_TIMEOUT)) { LOG_WRN("Failed locking modem cmds!"); }