From: Marc Kleine-Budde <mkl@pengutronix.de>
To: linux-can@vger.kernel.org
Cc: Marc Kleine-Budde <mkl@pengutronix.de>
Subject: [PATCH 5/9] can: bittiming: can_validate_bitrate(): simplify bit rate checking
Date: Mon, 24 Jan 2022 22:56:38 +0100 [thread overview]
Message-ID: <20220124215642.3474154-6-mkl@pengutronix.de> (raw)
In-Reply-To: <20220124215642.3474154-1-mkl@pengutronix.de>
This patch simplifies the validation of the fixed bit rates. If a
supported bit rate is found, directly return 0.
If no valid bit rate is found return -EINVAL;
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
---
drivers/net/can/dev/bittiming.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/net/can/dev/bittiming.c b/drivers/net/can/dev/bittiming.c
index d5fca3bfaf9a..1b1d1499e2f1 100644
--- a/drivers/net/can/dev/bittiming.c
+++ b/drivers/net/can/dev/bittiming.c
@@ -248,18 +248,14 @@ can_validate_bitrate(struct net_device *dev, struct can_bittiming *bt,
const u32 *bitrate_const,
const unsigned int bitrate_const_cnt)
{
- struct can_priv *priv = netdev_priv(dev);
unsigned int i;
for (i = 0; i < bitrate_const_cnt; i++) {
if (bt->bitrate == bitrate_const[i])
- break;
+ return 0;
}
- if (i >= priv->bitrate_const_cnt)
- return -EINVAL;
-
- return 0;
+ return -EINVAL;
}
int can_get_bittiming(struct net_device *dev, struct can_bittiming *bt,
--
2.34.1
next prev parent reply other threads:[~2022-01-25 2:37 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 21:56 [PATCH 0/9] dt-binding, bittiming and other cleanups Marc Kleine-Budde
2022-01-24 21:56 ` [PATCH 1/9] dt-binding: can: mcp251xfd: include common CAN controller bindings Marc Kleine-Budde
2022-01-24 21:56 ` [PATCH 2/9] dt-binding: can: sun4i_can: " Marc Kleine-Budde
2022-01-24 21:56 ` [PATCH 3/9] dt-binding: can: m_can: " Marc Kleine-Budde
2022-02-17 16:05 ` Chandrasekar R
2022-02-17 20:17 ` Marc Kleine-Budde
2022-01-24 21:56 ` [PATCH 4/9] dt-binding: can: rcar-can: " Marc Kleine-Budde
2022-01-24 21:56 ` Marc Kleine-Budde [this message]
2022-01-24 21:56 ` [PATCH 6/9] can: bittiming: mark function arguments and local variables as const Marc Kleine-Budde
2022-01-24 21:56 ` [PATCH 7/9] can: drivers: don't print IO remapped address of base registers Marc Kleine-Budde
2022-01-25 8:48 ` Alexandre Belloni
2022-01-24 21:56 ` [PATCH 8/9] can: kvaser_usb: kvaser_usb_send_cmd(): remove redundant variable actual_len Marc Kleine-Budde
2022-01-24 21:56 ` [PATCH 9/9] can: c_can: ethtool: use default drvinfo 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=20220124215642.3474154-6-mkl@pengutronix.de \
--to=mkl@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox