Skip to content

Commit 4238157

Browse files
George Spelvingregkh
authored andcommitted
pps: Additional cleanups in uart_handle_dcd_change
An extension of the previous commit, there is no semantic change here, just fewer lines of source code. Signed-off-by: George Spelvin <[email protected]> Acked-by: Rodolfo Giometti <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 593fb1a commit 4238157

File tree

1 file changed

+7
-10
lines changed

1 file changed

+7
-10
lines changed

drivers/tty/serial/serial_core.c

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2723,15 +2723,15 @@ EXPORT_SYMBOL(uart_match_port);
27232723
*/
27242724
void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
27252725
{
2726-
struct uart_state *state = uport->state;
2727-
struct tty_port *port = &state->port;
2728-
struct tty_ldisc *ld = NULL;
2726+
struct tty_port *port = &uport->state->port;
27292727
struct tty_struct *tty = port->tty;
2728+
struct tty_ldisc *ld = tty ? tty_ldisc_ref(tty) : NULL;
27302729

2731-
if (tty)
2732-
ld = tty_ldisc_ref(tty);
2733-
if (ld && ld->ops->dcd_change)
2734-
ld->ops->dcd_change(tty, status);
2730+
if (ld) {
2731+
if (ld->ops->dcd_change)
2732+
ld->ops->dcd_change(tty, status);
2733+
tty_ldisc_deref(ld);
2734+
}
27352735

27362736
uport->icount.dcd++;
27372737
#ifdef CONFIG_HARD_PPS
@@ -2745,9 +2745,6 @@ void uart_handle_dcd_change(struct uart_port *uport, unsigned int status)
27452745
else if (tty)
27462746
tty_hangup(tty);
27472747
}
2748-
2749-
if (ld)
2750-
tty_ldisc_deref(ld);
27512748
}
27522749
EXPORT_SYMBOL_GPL(uart_handle_dcd_change);
27532750

0 commit comments

Comments
 (0)