aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty/tty_buffer.c
diff options
context:
space:
mode:
authorJiri Slaby (SUSE) <[email protected]>2023-08-16 10:55:29 +0000
committerGreg Kroah-Hartman <[email protected]>2023-08-22 12:58:16 +0000
commit035197c908b57804b9407cf119d2c2fe5934ee00 (patch)
tree068c6f66e9b1635cffa8c9259aaba01200f8fee8 /drivers/tty/tty_buffer.c
parenttty: tty_buffer: better types in __tty_buffer_request_room() (diff)
downloadkernel-035197c908b57804b9407cf119d2c2fe5934ee00.tar.gz
kernel-035197c908b57804b9407cf119d2c2fe5934ee00.zip
tty: tty_buffer: initialize variables in initializers already
It makes the code both more compact, and more understandable. Signed-off-by: "Jiri Slaby (SUSE)" <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
Diffstat (limited to 'drivers/tty/tty_buffer.c')
-rw-r--r--drivers/tty/tty_buffer.c13
1 files changed, 3 insertions, 10 deletions
diff --git a/drivers/tty/tty_buffer.c b/drivers/tty/tty_buffer.c
index 414bb7f9155f..44c0adaec850 100644
--- a/drivers/tty/tty_buffer.c
+++ b/drivers/tty/tty_buffer.c
@@ -262,17 +262,10 @@ static int __tty_buffer_request_room(struct tty_port *port, size_t size,
bool flags)
{
struct tty_bufhead *buf = &port->buf;
- struct tty_buffer *b, *n;
- size_t left;
- bool change;
+ struct tty_buffer *n, *b = buf->tail;
+ size_t left = (b->flags ? 1 : 2) * b->size - b->used;
+ bool change = !b->flags && flags;
- b = buf->tail;
- if (!b->flags)
- left = 2 * b->size - b->used;
- else
- left = b->size - b->used;
-
- change = !b->flags && flags;
if (change || left < size) {
/* This is the slow path - looking for new buffers to use */
n = tty_buffer_alloc(port, size);