summaryrefslogtreecommitdiff
path: root/drivers/net/can/can327.c
diff options
context:
space:
mode:
authorJiri Slaby (SUSE) <jirislaby@kernel.org>2023-08-10 12:14:47 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2023-08-11 22:12:45 +0300
commit94b580e308c67922514af146a8793292d60a9b18 (patch)
treeb3c69be9a0cc412c9985611e2a16dffc4cbd753b /drivers/net/can/can327.c
parent8d9526f99fc39ebaca173eda646818023e7f0730 (diff)
downloadlinux-94b580e308c67922514af146a8793292d60a9b18.tar.xz
tty: can327: unify error paths in can327_ldisc_rx()
Create a label with can327_uart_side_failure() and spin unlock. And jump there from all three fail paths. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Max Staudt <max@enpas.org> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Marc Kleine-Budde <mkl@pengutronix.de> Cc: "David S. Miller" <davem@davemloft.net> Cc: Eric Dumazet <edumazet@google.com> Cc: Jakub Kicinski <kuba@kernel.org> Cc: Paolo Abeni <pabeni@redhat.com> Cc: linux-can@vger.kernel.org Link: https://lore.kernel.org/r/20230810091510.13006-14-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/net/can/can327.c')
-rw-r--r--drivers/net/can/can327.c22
1 files changed, 8 insertions, 14 deletions
diff --git a/drivers/net/can/can327.c b/drivers/net/can/can327.c
index ee8a977acc8d..05e9c035e8f6 100644
--- a/drivers/net/can/can327.c
+++ b/drivers/net/can/can327.c
@@ -905,11 +905,7 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,
if (fp && *fp++) {
netdev_err(elm->dev,
"Error in received character stream. Check your wiring.");
-
- can327_uart_side_failure(elm);
-
- spin_unlock_bh(&elm->lock);
- return;
+ goto uart_failure;
}
/* Ignore NUL characters, which the PIC microcontroller may
@@ -925,10 +921,7 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,
netdev_err(elm->dev,
"Received illegal character %02x.\n",
*cp);
- can327_uart_side_failure(elm);
-
- spin_unlock_bh(&elm->lock);
- return;
+ goto uart_failure;
}
elm->rxbuf[elm->rxfill++] = *cp;
@@ -941,15 +934,16 @@ static void can327_ldisc_rx(struct tty_struct *tty, const unsigned char *cp,
netdev_err(elm->dev,
"Receive buffer overflowed. Bad chip or wiring? count = %i",
count);
-
- can327_uart_side_failure(elm);
-
- spin_unlock_bh(&elm->lock);
- return;
+ goto uart_failure;
}
can327_parse_rxbuf(elm, first_new_char_idx);
spin_unlock_bh(&elm->lock);
+
+ return;
+uart_failure:
+ can327_uart_side_failure(elm);
+ spin_unlock_bh(&elm->lock);
}
/* Write out remaining transmit buffer.