Skip to content

Commit 73276e3

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: n_tty: use time_is_before_jiffies() in n_tty_receive_overrun()
The jiffies tests in n_tty_receive_overrun() are simplified ratelimiting (without locking). We could use struct ratelimit_state and the helpers, but to me, it occurs to be too complex for this use case. But the code currently tests both if the time passed (the first time_after()) and if jiffies wrapped around (the second time_after()). time_is_before_jiffies() takes care of both, provided overrun_time is initialized at the allocation time. So switch to time_is_before_jiffies(), the same what ratelimiting does. Signed-off-by: "Jiri Slaby (SUSE)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 68d90d5 commit 73276e3

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

drivers/tty/n_tty.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,8 +1173,7 @@ static void n_tty_receive_overrun(const struct tty_struct *tty)
11731173
struct n_tty_data *ldata = tty->disc_data;
11741174

11751175
ldata->num_overrun++;
1176-
if (time_after(jiffies, ldata->overrun_time + HZ) ||
1177-
time_after(ldata->overrun_time, jiffies)) {
1176+
if (time_is_before_jiffies(ldata->overrun_time + HZ)) {
11781177
tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun);
11791178
ldata->overrun_time = jiffies;
11801179
ldata->num_overrun = 0;

0 commit comments

Comments
 (0)