[PATCH 4/5] can: bittiming: can_calc_bittiming(): ensure that SJW is not longer than either Phase Buffer Segment

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to "The Configuration of the CAN Bit Timing" [1] the SJW
"may not be longer than either Phase Buffer Segment".

Use bt->phase_seg2 instead of tseg2 (technically these are the same
values). Include bt->phase_seg1 in the limit check, too.

[1] http://web.archive.org/http://www.oertel-halle.de/files/cia99paper.pdf

Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
---
 drivers/net/can/dev/calc_bittiming.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/net/can/dev/calc_bittiming.c b/drivers/net/can/dev/calc_bittiming.c
index cb9521c8ae8e..b9aa1f7d0b37 100644
--- a/drivers/net/can/dev/calc_bittiming.c
+++ b/drivers/net/can/dev/calc_bittiming.c
@@ -158,8 +158,9 @@ int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt,
 	if (!bt->sjw)
 		bt->sjw = 1;
 
-	/* sjw must not be higher than sjw_max and tseg2 */
-	bt->sjw = min3(bt->sjw, btc->sjw_max, tseg2);
+	/* sjw must not be higher than sjw_max, phase_seg1, and phase_seg2 */
+	bt->sjw = min3(bt->sjw, btc->sjw_max,
+		       min(bt->phase_seg1, bt->phase_seg2));
 
 	bt->brp = best_brp;
 
-- 
2.35.1





[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux