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 <robert.lubos@nordicsemi.no>
This commit is contained in:
Robert Lubos 2021-04-08 15:36:30 +02:00 committed by Anas Nashif
commit 501c7d17b0
2 changed files with 8 additions and 7 deletions

View file

@ -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;

View file

@ -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,