Skip to content

Commit 3ae9959

Browse files
Jiri Slaby (SUSE)gregkh
authored andcommitted
tty: n_hdlc: simplify return from n_hdlc_tty_ioctl()
The cases in the switch() of n_hdlc_tty_ioctl() can return immediately -- no need to store into error and return later. Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org> Link: https://patch.msgid.link/20251119100140.830761-4-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2fc541e commit 3ae9959

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

drivers/tty/n_hdlc.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -584,7 +584,6 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
584584
unsigned long arg)
585585
{
586586
struct n_hdlc *n_hdlc = tty->disc_data;
587-
int error = 0;
588587
int count;
589588
unsigned long flags;
590589
struct n_hdlc_buf *buf = NULL;
@@ -603,8 +602,7 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
603602
else
604603
count = 0;
605604
spin_unlock_irqrestore(&n_hdlc->rx_buf_list.spinlock, flags);
606-
error = put_user(count, (int __user *)arg);
607-
break;
605+
return put_user(count, (int __user *)arg);
608606

609607
case TIOCOUTQ:
610608
/* get the pending tx byte count in the driver */
@@ -616,8 +614,7 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
616614
if (buf)
617615
count += buf->count;
618616
spin_unlock_irqrestore(&n_hdlc->tx_buf_list.spinlock, flags);
619-
error = put_user(count, (int __user *)arg);
620-
break;
617+
return put_user(count, (int __user *)arg);
621618

622619
case TCFLSH:
623620
switch (arg) {
@@ -628,11 +625,8 @@ static int n_hdlc_tty_ioctl(struct tty_struct *tty, unsigned int cmd,
628625
fallthrough; /* to default */
629626

630627
default:
631-
error = n_tty_ioctl_helper(tty, cmd, arg);
632-
break;
628+
return n_tty_ioctl_helper(tty, cmd, arg);
633629
}
634-
return error;
635-
636630
} /* end of n_hdlc_tty_ioctl() */
637631

638632
/**

0 commit comments

Comments
 (0)