From 501c7d17b01485ed04fd5c6fc91c99e47c9c7e99 Mon Sep 17 00:00:00 2001 From: Robert Lubos Date: Thu, 8 Apr 2021 15:36:30 +0200 Subject: [PATCH] shell: telnet: Update to the new k_work API Update the shell telnet backend to use the new k_work_delayable API. Fixes #34100 Signed-off-by: Robert Lubos --- include/shell/shell_telnet.h | 2 +- subsys/shell/shell_telnet.c | 13 +++++++------ 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/shell/shell_telnet.h b/include/shell/shell_telnet.h index 42eb6a3a4e4..b183c0694d6 100644 --- a/include/shell/shell_telnet.h +++ b/include/shell/shell_telnet.h @@ -45,7 +45,7 @@ struct shell_telnet { * been around for "too long". This will prove to be useful * to send the shell prompt for instance. */ - struct k_delayed_work send_work; + struct k_work_delayable send_work; /** If set, no output is sent to the TELNET client. */ bool output_lock; diff --git a/subsys/shell/shell_telnet.c b/subsys/shell/shell_telnet.c index 7618c288c64..d9f9dcf3c2b 100644 --- a/subsys/shell/shell_telnet.c +++ b/subsys/shell/shell_telnet.c @@ -43,7 +43,7 @@ static void telnet_end_client_connection(void) sh_telnet->client_ctx = NULL; sh_telnet->output_lock = false; - k_delayed_work_cancel(&sh_telnet->send_work); + k_work_cancel_delayable(&sh_telnet->send_work); /* Flush the RX FIFO */ while ((pkt = k_fifo_get(&sh_telnet->rx_fifo, K_NO_WAIT)) != NULL) { @@ -109,7 +109,7 @@ static void telnet_reply_command(struct telnet_simple_command *cmd) /* OK, no output then */ sh_telnet->output_lock = true; sh_telnet->line_out.len = 0; - k_delayed_work_cancel(&sh_telnet->send_work); + k_work_cancel_delayable(&sh_telnet->send_work); break; case NVT_CMD_AYT: telnet_reply_ay_command(); @@ -343,7 +343,7 @@ static int init(const struct shell_transport *transport, sh_telnet->shell_context = context; k_fifo_init(&sh_telnet->rx_fifo); - k_delayed_work_init(&sh_telnet->send_work, telnet_send_prematurely); + k_work_init_delayable(&sh_telnet->send_work, telnet_send_prematurely); return 0; } @@ -389,8 +389,9 @@ static int write(const struct shell_transport *transport, /* Stop the transmission timer, so it does not interrupt the operation. */ - timeout = k_delayed_work_remaining_get(&sh_telnet->send_work); - k_delayed_work_cancel(&sh_telnet->send_work); + timeout = k_ticks_to_ms_ceil32( + k_work_delayable_remaining_get(&sh_telnet->send_work)); + k_work_cancel_delayable(&sh_telnet->send_work); do { if (lb->len + length - *cnt > TELNET_LINE_SIZE) { @@ -422,7 +423,7 @@ static int write(const struct shell_transport *transport, */ timeout = (timeout == 0) ? TELNET_TIMEOUT : timeout; - k_delayed_work_submit(&sh_telnet->send_work, K_MSEC(timeout)); + k_work_reschedule(&sh_telnet->send_work, K_MSEC(timeout)); } sh_telnet->shell_handler(SHELL_TRANSPORT_EVT_TX_RDY,