Commit fdfa49a8 authored by Jiri Slaby (SUSE)'s avatar Jiri Slaby (SUSE) Committed by Greg Kroah-Hartman
Browse files

tty: n_tty: simplify process_output()



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

Signed-off-by: default avatarJiri Slaby (SUSE) <jirislaby@kernel.org>
Link: https://lore.kernel.org/r/20250317070046.24386-7-jirislaby@kernel.org


Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent d97aa066
Loading
Loading
Loading
Loading
+4 −10
Original line number Diff line number Diff line
@@ -488,18 +488,12 @@ static int do_output_char(u8 c, struct tty_struct *tty, int space)
static int process_output(u8 c, struct tty_struct *tty)
{
	struct n_tty_data *ldata = tty->disc_data;
	unsigned int space;
	int retval;

	mutex_lock(&ldata->output_lock);

	space = tty_write_room(tty);
	retval = do_output_char(c, tty, space);
	guard(mutex)(&ldata->output_lock);

	mutex_unlock(&ldata->output_lock);
	if (retval < 0)
	if (do_output_char(c, tty, tty_write_room(tty)) < 0)
		return -1;
	else

	return 0;
}