diff options
author | Jiri Slaby (SUSE) <jirislaby@kernel.org> | 2023-08-27 09:41:37 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-08-27 11:46:52 +0200 |
commit | 73276e3a1097ff58d9d167fc9a593cc249d1fd6f (patch) | |
tree | 6488c21497d8322bf0f00b93a985c3c03bc2b486 /drivers/tty/n_tty.c | |
parent | tty: n_tty: use 'num' for writes' counts (diff) | |
download | linux-73276e3a1097ff58d9d167fc9a593cc249d1fd6f.tar.xz linux-73276e3a1097ff58d9d167fc9a593cc249d1fd6f.zip |
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)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230827074147.2287-5-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty/n_tty.c')
-rw-r--r-- | drivers/tty/n_tty.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 7f9fee4cf7cf..c0b23e975877 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -1173,8 +1173,7 @@ static void n_tty_receive_overrun(const struct tty_struct *tty) struct n_tty_data *ldata = tty->disc_data; ldata->num_overrun++; - if (time_after(jiffies, ldata->overrun_time + HZ) || - time_after(ldata->overrun_time, jiffies)) { + if (time_is_before_jiffies(ldata->overrun_time + HZ)) { tty_warn(tty, "%d input overrun(s)\n", ldata->num_overrun); ldata->overrun_time = jiffies; ldata->num_overrun = 0; |