Skip to content

Commit

Permalink
mxser: use msleep_interruptible() in mxser_wait_until_sent()
Browse files Browse the repository at this point in the history
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 <jslaby@suse.cz>
Link: https://lore.kernel.org/r/20211118073125.12283-13-jslaby@suse.cz
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jiri Slaby authored and Greg Kroah-Hartman committed Nov 25, 2021
1 parent 239ef19 commit fe74bc6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions drivers/tty/mxser.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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);
}

/*
Expand Down

0 comments on commit fe74bc6

Please sign in to comment.