diff options
author | Jiri Slaby (SUSE) <jirislaby@kernel.org> | 2023-08-27 09:41:43 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-08-27 11:46:52 +0200 |
commit | d88c3c2675f9d41c15297fa001e79812f4dcc9dd (patch) | |
tree | c0fccd1f8a9e450515a6514ec3ff4de9c8bd2ed3 /drivers/tty | |
parent | 046b44ab0f5a87ba5788606155c5a6761169616a (diff) |
tty: n_tty: simplify chars_in_buffer()
The 'if' in chars_in_buffer() is misleadingly inverted. And since the
only difference is the head used for computation, cache the head using
ternary operator. And use that in return directly.
Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230827074147.2287-11-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r-- | drivers/tty/n_tty.c | 8 |
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/tty/n_tty.c b/drivers/tty/n_tty.c index 369f5dd9cc4b..e722065b2db4 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -219,13 +219,9 @@ static void n_tty_kick_worker(const struct tty_struct *tty) static ssize_t chars_in_buffer(const struct tty_struct *tty) { const struct n_tty_data *ldata = tty->disc_data; - ssize_t n = 0; + size_t head = ldata->icanon ? ldata->canon_head : ldata->commit_head; - if (!ldata->icanon) - n = ldata->commit_head - ldata->read_tail; - else - n = ldata->canon_head - ldata->read_tail; - return n; + return head - ldata->read_tail; } /** |