Skip to content

Commit b2bb1ff

Browse files
joerchankartben
authored andcommitted
drivers: modem: Use modem command await function
Use the modem command await function where appropriate. Signed-off-by: Joakim Andersson <joerchan@gmail.com>
1 parent 2534141 commit b2bb1ff

File tree

2 files changed

+3
-20
lines changed

2 files changed

+3
-20
lines changed

drivers/modem/modem_cmd_handler.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -570,13 +570,7 @@ int modem_cmd_send_ext(struct modem_iface *iface,
570570
iface->write(iface, data->eol, data->eol_len);
571571

572572
if (sem) {
573-
ret = k_sem_take(sem, timeout);
574-
575-
if (ret == 0) {
576-
ret = data->last_error;
577-
} else if (ret == -EAGAIN) {
578-
ret = -ETIMEDOUT;
579-
}
573+
ret = modem_cmd_handler_await(data, sem, timeout);
580574
}
581575

582576
if (!(flags & MODEM_NO_UNSET_CMDS)) {

drivers/modem/ublox-sara-r4.c

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -423,13 +423,8 @@ static ssize_t send_socket_data(void *obj,
423423
ret = 0;
424424
goto exit;
425425
}
426-
ret = k_sem_take(&mdata.sem_response, timeout);
427426

428-
if (ret == 0) {
429-
ret = modem_cmd_handler_get_error(&mdata.cmd_handler_data);
430-
} else if (ret == -EAGAIN) {
431-
ret = -ETIMEDOUT;
432-
}
427+
ret = modem_cmd_handler_await(&mdata.cmd_handler_data, &mdata.sem_response, timeout);
433428

434429
exit:
435430
/* unset handler commands and ignore any errors */
@@ -496,13 +491,7 @@ static ssize_t send_cert(struct modem_socket *sock,
496491
k_sleep(MDM_PROMPT_CMD_DELAY);
497492
modem_cmd_send_data_nolock(&mctx.iface, cert_data, cert_len);
498493

499-
ret = k_sem_take(&mdata.sem_response, K_MSEC(1000));
500-
501-
if (ret == 0) {
502-
ret = modem_cmd_handler_get_error(&mdata.cmd_handler_data);
503-
} else if (ret == -EAGAIN) {
504-
ret = -ETIMEDOUT;
505-
}
494+
ret = modem_cmd_handler_await(&mdata.cmd_handler_data, &mdata.sem_response, K_MSEC(1000));
506495

507496
exit:
508497
/* unset handler commands and ignore any errors */

0 commit comments

Comments
 (0)