Prepare the SJW handling in can_calc_bittiming() for the changes coming in the next patches. Always ensure that SJW in within the limits. Signed-off-by: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx> --- drivers/net/can/dev/calc_bittiming.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/net/can/dev/calc_bittiming.c b/drivers/net/can/dev/calc_bittiming.c index ce6bef2444a2..cb9521c8ae8e 100644 --- a/drivers/net/can/dev/calc_bittiming.c +++ b/drivers/net/can/dev/calc_bittiming.c @@ -154,13 +154,12 @@ int can_calc_bittiming(const struct net_device *dev, struct can_bittiming *bt, bt->phase_seg1 = tseg1 - bt->prop_seg; bt->phase_seg2 = tseg2; - /* check for sjw user settings */ - if (!bt->sjw || !btc->sjw_max) { + /* If user space provides no sjw, use 1 as default */ + if (!bt->sjw) bt->sjw = 1; - } else { - /* 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 and tseg2 */ + bt->sjw = min3(bt->sjw, btc->sjw_max, tseg2); bt->brp = best_brp; -- 2.35.1