summaryrefslogtreecommitdiff
path: root/drivers/net/can/dev/bittiming.c
diff options
context:
space:
mode:
authorMarc Kleine-Budde <mkl@pengutronix.de>2023-01-31 17:11:55 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2023-02-06 13:57:25 +0100
commit89cfa63565606bf462b4fdc0bd3e91a7cece1380 (patch)
tree27aa67af23ecaae8603623d72b5826d7dccea40e /drivers/net/can/dev/bittiming.c
parent36207c34d17fb573ddaa7c024d2c9c6eef1b8532 (diff)
can: bittiming(): replace open coded variants of can_bit_time()
Commit 1c47fa6b31c2 ("can: dev: add a helper function to calculate the duration of one bit") added the helper function can_bit_time(). Replace open coded variants of can_bit_time() by the helper function. Link: https://lore.kernel.org/all/20230202110854.2318594-2-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can/dev/bittiming.c')
-rw-r--r--drivers/net/can/dev/bittiming.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/drivers/net/can/dev/bittiming.c b/drivers/net/can/dev/bittiming.c
index 7ae80763c960..32af609eee50 100644
--- a/drivers/net/can/dev/bittiming.c
+++ b/drivers/net/can/dev/bittiming.c
@@ -15,7 +15,7 @@ static int can_fixup_bittiming(const struct net_device *dev, struct can_bittimin
const struct can_bittiming_const *btc)
{
const struct can_priv *priv = netdev_priv(dev);
- unsigned int tseg1, alltseg;
+ unsigned int tseg1;
u64 brp64;
tseg1 = bt->prop_seg + bt->phase_seg1;
@@ -38,9 +38,8 @@ static int can_fixup_bittiming(const struct net_device *dev, struct can_bittimin
if (bt->brp < btc->brp_min || bt->brp > btc->brp_max)
return -EINVAL;
- alltseg = bt->prop_seg + bt->phase_seg1 + bt->phase_seg2 + 1;
- bt->bitrate = priv->clock.freq / (bt->brp * alltseg);
- bt->sample_point = ((tseg1 + 1) * 1000) / alltseg;
+ bt->bitrate = priv->clock.freq / (bt->brp * can_bit_time(bt));
+ bt->sample_point = ((tseg1 + 1) * 1000) / can_bit_time(bt);
return 0;
}