Skip to content

Commit 6661968

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: early return from send_break() on TTY_DRIVER_HARDWARE_BREAK
If the driver sets TTY_DRIVER_HARDWARE_BREAK, we leave ops->break_ctl() to the driver and return from send_break(). But we do it using a local variable and keep the code flowing through the end of the function. Instead, do 'return' immediately with the ops->break_ctl()'s return value. This way, we don't have to stuff the 'else' branch of the 'if' with the software break handling. And we can re-indent the function too. 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 e5d0424 commit 6661968

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

drivers/tty/tty_io.c

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,22 +2475,24 @@ static int send_break(struct tty_struct *tty, unsigned int duration)
24752475
return 0;
24762476

24772477
if (tty->driver->flags & TTY_DRIVER_HARDWARE_BREAK)
2478-
retval = tty->ops->break_ctl(tty, duration);
2479-
else {
2480-
/* Do the work ourselves */
2481-
if (tty_write_lock(tty, false) < 0)
2482-
return -EINTR;
2483-
retval = tty->ops->break_ctl(tty, -1);
2484-
if (retval)
2485-
goto out;
2486-
if (!signal_pending(current))
2487-
msleep_interruptible(duration);
2488-
retval = tty->ops->break_ctl(tty, 0);
2478+
return tty->ops->break_ctl(tty, duration);
2479+
2480+
/* Do the work ourselves */
2481+
if (tty_write_lock(tty, false) < 0)
2482+
return -EINTR;
2483+
2484+
retval = tty->ops->break_ctl(tty, -1);
2485+
if (retval)
2486+
goto out;
2487+
if (!signal_pending(current))
2488+
msleep_interruptible(duration);
2489+
retval = tty->ops->break_ctl(tty, 0);
24892490
out:
2490-
tty_write_unlock(tty);
2491-
if (signal_pending(current))
2492-
retval = -EINTR;
2493-
}
2491+
tty_write_unlock(tty);
2492+
2493+
if (signal_pending(current))
2494+
retval = -EINTR;
2495+
24942496
return retval;
24952497
}
24962498

0 commit comments

Comments
 (0)