All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-can@vger.kernel.org
Cc: kernel@pengutronix.de, Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH v2 3/5] can: dev: can_restart(): reverse logic to remove need for goto
Date: Thu, 05 Oct 2023 09:48:20 +0200	[thread overview]
Message-ID: <20231005-can-dev-fix-can-restart-v2-3-91b5c1fd922c@pengutronix.de> (raw)
In-Reply-To: <20231005-can-dev-fix-can-restart-v2-0-91b5c1fd922c@pengutronix.de>

Reverse the logic in the if statement and eliminate the need for a
goto to simplify code readability.

Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
 drivers/net/can/dev/dev.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/net/can/dev/dev.c b/drivers/net/can/dev/dev.c
index 735d5de3caa0..9014256c486a 100644
--- a/drivers/net/can/dev/dev.c
+++ b/drivers/net/can/dev/dev.c
@@ -142,14 +142,11 @@ static void can_restart(struct net_device *dev)
 
 	/* send restart message upstream */
 	skb = alloc_can_err_skb(dev, &cf);
-	if (!skb)
-		goto restart;
+	if (skb) {
+		cf->can_id |= CAN_ERR_RESTARTED;
+		netif_rx(skb);
+	}
 
-	cf->can_id |= CAN_ERR_RESTARTED;
-
-	netif_rx(skb);
-
-restart:
 	netdev_dbg(dev, "restarted\n");
 	priv->can_stats.restarts++;
 

-- 
2.40.1



  parent reply	other threads:[~2023-10-05 16:13 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-05  7:48 [PATCH v2 0/5] can: dev: fix can_restart() and replace BUG_ON() by error handling Marc Kleine-Budde
2023-10-05  7:48 ` [PATCH v2 1/5] can: dev: can_restart(): don't crash kernel if carrier is OK Marc Kleine-Budde
2023-10-05  7:48 ` [PATCH v2 2/5] can: dev: can_restart(): fix race condition between controller restart and netif_carrier_on() Marc Kleine-Budde
2023-10-05  7:48 ` Marc Kleine-Budde [this message]
2023-10-05  7:48 ` [PATCH v2 4/5] can: dev: can_restart(): update debug and error messages Marc Kleine-Budde
2023-10-05 16:06   ` Vincent Mailhol
2023-10-05 19:36     ` Marc Kleine-Budde
2023-10-05  7:48 ` [PATCH v2 5/5] can: dev: can_put_echo_skb(): don't crash kernel if can_priv::echo_skb is accessed out of bounds Marc Kleine-Budde
2023-10-05 16:07 ` [PATCH v2 0/5] can: dev: fix can_restart() and replace BUG_ON() by error handling Vincent Mailhol
2023-10-05 18:20   ` Marc Kleine-Budde

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231005-can-dev-fix-can-restart-v2-3-91b5c1fd922c@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=kernel@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.