summaryrefslogtreecommitdiff
path: root/drivers/tty/mxser.c
diff options
context:
space:
mode:
authorJiri Slaby <jslaby@suse.cz>2021-11-18 10:31:19 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-11-25 20:33:22 +0300
commit49b798a69e2b1b8c9de6df66a5b8ccf090583551 (patch)
tree95ba6e1e12ce8f7da6f7998db3d60a775cad5658 /drivers/tty/mxser.c
parentfe74bc619b0db23c4b513141acd3e3e45694bb08 (diff)
downloadlinux-49b798a69e2b1b8c9de6df66a5b8ccf090583551.tar.xz
mxser: clean up timeout handling in mxser_wait_until_sent()
timeout cannot be zero at the point of use. So no need to check for zero. Also precompute the expiration time (into expire) and use it. This makes the code more clear. Signed-off-by: Jiri Slaby <jslaby@suse.cz> Link: https://lore.kernel.org/r/20211118073125.12283-14-jslaby@suse.cz Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/mxser.c')
-rw-r--r--drivers/tty/mxser.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/tty/mxser.c b/drivers/tty/mxser.c
index b3ae3b105af0..c3f262dc936d 100644
--- a/drivers/tty/mxser.c
+++ b/drivers/tty/mxser.c
@@ -1420,7 +1420,7 @@ static bool mxser_tx_empty(struct mxser_port *info)
static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
{
struct mxser_port *info = tty->driver_data;
- unsigned long orig_jiffies, char_time;
+ unsigned long expire, char_time;
if (info->type == PORT_UNKNOWN)
return;
@@ -1428,7 +1428,6 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
if (info->xmit_fifo_size == 0)
return; /* Just in case.... */
- orig_jiffies = jiffies;
/*
* Set the check interval to be 1/5 of the estimated time to
* send a single character, and make it at least 1. The check
@@ -1458,11 +1457,13 @@ static void mxser_wait_until_sent(struct tty_struct *tty, int timeout)
if (!timeout || timeout > 2 * info->timeout)
timeout = 2 * info->timeout;
+ expire = jiffies + timeout;
+
while (mxser_tx_empty(info)) {
msleep_interruptible(char_time);
if (signal_pending(current))
break;
- if (timeout && time_after(jiffies, orig_jiffies + timeout))
+ if (time_after(jiffies, expire))
break;
}
}