Skip to content

Commit

Permalink
can: bittiming: can_fixup_bittiming(): use CAN_SYNC_SEG instead of 1
Browse files Browse the repository at this point in the history
Commit 1c47fa6 ("can: dev: add a helper function to calculate the
duration of one bit") made the constant CAN_SYNC_SEG available in a
header file.

The magic number 1 in can_fixup_bittiming() represents the width of
the sync segment, replace it by CAN_SYNC_SEG to make the code more
readable.

Link: https://lore.kernel.org/all/20230202110854.2318594-3-mkl@pengutronix.de
Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
  • Loading branch information
Marc Kleine-Budde committed Feb 6, 2023
1 parent 89cfa63 commit 9cf670d
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/net/can/dev/bittiming.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static int can_fixup_bittiming(const struct net_device *dev, struct can_bittimin
return -EINVAL;

bt->bitrate = priv->clock.freq / (bt->brp * can_bit_time(bt));
bt->sample_point = ((tseg1 + 1) * 1000) / can_bit_time(bt);
bt->sample_point = ((CAN_SYNC_SEG + tseg1) * 1000) / can_bit_time(bt);

return 0;
}
Expand Down

0 comments on commit 9cf670d

Please sign in to comment.