Skip to content

Commit 8e50e6b

Browse files
pabigotjukkar
authored andcommitted
drivers: console: mux: Conversion of k_work API
Replace all existing deprecated API with the recommended alternative for gsm_mux and uart_mux drivers. Fixes zephyrproject-rtos#34103 Signed-off-by: Peter Bigot <[email protected]> Signed-off-by: Jukka Rissanen <[email protected]>
1 parent 5a2a392 commit 8e50e6b

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

drivers/console/gsm_mux.c

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ struct gsm_mux {
9191
uint16_t msg_len; /* message length */
9292
uint16_t received; /* bytes so far received */
9393

94-
struct k_delayed_work t2_timer;
94+
struct k_work_delayable t2_timer;
9595
sys_slist_t pending_ctrls;
9696

9797
uint16_t t1_timeout_value; /* T1 default value */
@@ -169,7 +169,7 @@ static struct gsm_mux muxes[CONFIG_GSM_MUX_MAX];
169169
static struct gsm_dlci dlcis[CONFIG_GSM_MUX_DLCI_MAX];
170170
static sys_slist_t dlci_free_entries;
171171
static sys_slist_t dlci_active_t1_timers;
172-
static struct k_delayed_work t1_timer;
172+
static struct k_work_delayable t1_timer;
173173

174174
static struct gsm_control_msg ctrls[CONFIG_GSM_MUX_PENDING_CMD_MAX];
175175
static sys_slist_t ctrls_free_entries;
@@ -454,9 +454,7 @@ static void dlci_run_timer(uint32_t current_time)
454454
struct gsm_dlci *dlci, *next;
455455
uint32_t new_timer = UINT_MAX;
456456

457-
if (k_delayed_work_remaining_get(&t1_timer)) {
458-
k_delayed_work_cancel(&t1_timer);
459-
}
457+
(void)k_work_cancel_delayable(&t1_timer);
460458

461459
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&dlci_active_t1_timers,
462460
dlci, next, node) {
@@ -467,7 +465,7 @@ static void dlci_run_timer(uint32_t current_time)
467465
}
468466

469467
if (new_timer != UINT_MAX) {
470-
k_delayed_work_submit(&t1_timer, K_MSEC(new_timer));
468+
k_work_reschedule(&t1_timer, K_MSEC(new_timer));
471469
}
472470
}
473471

@@ -631,9 +629,9 @@ static void gsm_mux_t2_timeout(struct k_work *work)
631629
}
632630

633631
if (entry) {
634-
k_delayed_work_submit(&mux->t2_timer,
635-
K_MSEC(entry->req_start + T2_MSEC -
636-
current_time));
632+
k_work_reschedule(
633+
&mux->t2_timer,
634+
K_MSEC(entry->req_start + T2_MSEC - current_time));
637635
}
638636
}
639637

@@ -674,8 +672,8 @@ static int gsm_mux_send_control_message(struct gsm_mux *mux, uint8_t dlci_addres
674672
ctrl->req_start = k_uptime_get_32();
675673

676674
/* Let's start the timer if necessary */
677-
if (!k_delayed_work_remaining_get(&mux->t2_timer)) {
678-
k_delayed_work_submit(&mux->t2_timer, K_MSEC(T2_MSEC));
675+
if (!k_work_delayable_remaining_get(&mux->t2_timer)) {
676+
k_work_reschedule(&mux->t2_timer, K_MSEC(T2_MSEC));
679677
}
680678

681679
return gsm_mux_modem_send(mux, buf->data, buf->len);
@@ -692,9 +690,9 @@ static int gsm_dlci_opening_or_closing(struct gsm_dlci *dlci,
692690
dlci->command_cb = cb;
693691

694692
/* Let's start the timer if necessary */
695-
if (!k_delayed_work_remaining_get(&t1_timer)) {
696-
k_delayed_work_submit(&t1_timer,
697-
K_MSEC(dlci->mux->t1_timeout_value));
693+
if (!k_work_delayable_remaining_get(&t1_timer)) {
694+
k_work_reschedule(&t1_timer,
695+
K_MSEC(dlci->mux->t1_timeout_value));
698696
}
699697

700698
sys_slist_append(&dlci_active_t1_timers, &dlci->node);
@@ -739,7 +737,7 @@ int gsm_mux_disconnect(struct gsm_mux *mux, k_timeout_t timeout)
739737
(void)gsm_mux_send_control_message(dlci->mux, dlci->num,
740738
CMD_CLD, NULL, 0);
741739

742-
k_delayed_work_cancel(&mux->t2_timer);
740+
(void)k_work_cancel_delayable(&mux->t2_timer);
743741

744742
(void)gsm_dlci_closing(dlci, NULL);
745743

@@ -1474,7 +1472,7 @@ struct gsm_mux *gsm_mux_create(const struct device *uart)
14741472
mux->state = GSM_MUX_SOF;
14751473
mux->buf = NULL;
14761474

1477-
k_delayed_work_init(&mux->t2_timer, gsm_mux_t2_timeout);
1475+
k_work_init_delayable(&mux->t2_timer, gsm_mux_t2_timeout);
14781476
sys_slist_init(&mux->pending_ctrls);
14791477

14801478
/* The system will continue after the control DLCI is
@@ -1538,5 +1536,5 @@ void gsm_mux_init(void)
15381536
sys_slist_prepend(&dlci_free_entries, &dlcis[i].node);
15391537
}
15401538

1541-
k_delayed_work_init(&t1_timer, dlci_t1_timeout);
1539+
k_work_init_delayable(&t1_timer, dlci_t1_timeout);
15421540
}

drivers/console/uart_mux.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -901,9 +901,9 @@ static int init_uart_mux(const struct device *dev)
901901
{
902902
ARG_UNUSED(dev);
903903

904-
k_work_q_start(&uart_mux_workq, uart_mux_stack,
905-
K_KERNEL_STACK_SIZEOF(uart_mux_stack),
906-
K_PRIO_COOP(UART_MUX_WORKQ_PRIORITY));
904+
k_work_queue_start(&uart_mux_workq, uart_mux_stack,
905+
K_KERNEL_STACK_SIZEOF(uart_mux_stack),
906+
K_PRIO_COOP(UART_MUX_WORKQ_PRIORITY), NULL);
907907
k_thread_name_set(&uart_mux_workq.thread, "uart_mux_workq");
908908

909909
return 0;

0 commit comments

Comments
 (0)