diff options
author | Jiri Slaby (SUSE) <jirislaby@kernel.org> | 2023-09-19 10:51:44 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2023-10-03 14:31:15 +0200 |
commit | 72369f2d493d4c0f4f0ed5a66b19c6912c4837ef (patch) | |
tree | cc319b10ba6fe68220feee01fbb24c1d0c12cf3c /drivers/tty/n_tty.c | |
parent | 1e619477a9c8d6e2ec05a53cda97558fdf9f440e (diff) |
tty: n_tty: use min3() in copy_from_read_buf()
n is a minimum of:
* available chars in the ring buffer
* available chars in the ring buffer till the end of the ring buffer
* requested number (*nr)
We can use min3() for that instead of two min()s.
Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20230919085156.1578-4-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 e917faa0b84c..6a112910c058 100644 --- a/drivers/tty/n_tty.c +++ b/drivers/tty/n_tty.c @@ -1965,8 +1965,7 @@ static bool copy_from_read_buf(const struct tty_struct *tty, u8 **kbp, size_t head = smp_load_acquire(&ldata->commit_head); size_t tail = MASK(ldata->read_tail); - n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail); - n = min(*nr, n); + n = min3(head - ldata->read_tail, N_TTY_BUF_SIZE - tail, *nr); if (n) { u8 *from = read_buf_addr(ldata, tail); memcpy(*kbp, from, n); |