Skip to content

Commit fdfa49a

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
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) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent d97aa06 commit fdfa49a

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

drivers/tty/n_tty.c

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -488,19 +488,13 @@ static int do_output_char(u8 c, struct tty_struct *tty, int space)
488488
static int process_output(u8 c, struct tty_struct *tty)
489489
{
490490
struct n_tty_data *ldata = tty->disc_data;
491-
unsigned int space;
492-
int retval;
493491

494-
mutex_lock(&ldata->output_lock);
492+
guard(mutex)(&ldata->output_lock);
495493

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)
501495
return -1;
502-
else
503-
return 0;
496+
497+
return 0;
504498
}
505499

506500
/**

0 commit comments

Comments
 (0)