Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: n_tty: simplify process_output()

Using guard(mutex), the function can be written in a much more efficient
way.

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250317070046.24386-7-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
fdfa49a8 d97aa066

+4 -10
+4 -10
drivers/tty/n_tty.c
··· 488 488 static int process_output(u8 c, struct tty_struct *tty) 489 489 { 490 490 struct n_tty_data *ldata = tty->disc_data; 491 - unsigned int space; 492 - int retval; 493 491 494 - mutex_lock(&ldata->output_lock); 492 + guard(mutex)(&ldata->output_lock); 495 493 496 - space = tty_write_room(tty); 497 - retval = do_output_char(c, tty, space); 498 - 499 - mutex_unlock(&ldata->output_lock); 500 - if (retval < 0) 494 + if (do_output_char(c, tty, tty_write_room(tty)) < 0) 501 495 return -1; 502 - else 503 - return 0; 496 + 497 + return 0; 504 498 } 505 499 506 500 /**