Thread (21 messages) 21 messages, 2 authors, 2021-11-18
STALE1712d LANDED

[PATCH 12/19] mxser: use msleep_interruptible() in mxser_wait_until_sent()

From: Jiri Slaby <hidden>
Date: 2021-11-18 07:32:40
Also in: lkml
Subsystem: moxa smartio/industio/intellio serial card, the rest, tty layer and serial drivers · Maintainers: Jiri Slaby, Linus Torvalds, Greg Kroah-Hartman

Instead of schedule_timeout_interruptible(), because:
1) we don't have to bother with the task state, and
2) msleep* guarantees to sleep that time (if not interrupted).

Signed-off-by: Jiri Slaby <redacted>
---
 drivers/tty/mxser.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index fb26670b5a0b..b3ae3b105af0 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1443,6 +1443,9 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
 		char_time = 1;
 	if (timeout && timeout < char_time)
 		char_time = timeout;
+
+	char_time = jiffies_to_msecs(char_time);
+
 	/*
 	 * If the transmitter hasn't cleared in twice the approximate
 	 * amount of time to send the entire FIFO, it probably won't
@@ -1456,13 +1459,12 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
 		timeout = 2 * info->timeout;
 
 	while (mxser_tx_empty(info)) {
-		schedule_timeout_interruptible(char_time);
+		msleep_interruptible(char_time);
 		if (signal_pending(current))
 			break;
 		if (timeout && time_after(jiffies, orig_jiffies + timeout))
 			break;
 	}
-	set_current_state(TASK_RUNNING);
 }
 
 /*
-- 
2.33.1
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help