Lines Matching +full:parameter +full:- +full:less
1 // SPDX-License-Identifier: GPL-2.0-only
2 /* Copyright (C) 2005 Marc Kleine-Budde, Pengutronix
4 * Copyright (C) 2008-2009 Wolfgang Grandegger <wg@grandegger.com>
11 if (bt->sjw) in can_sjw_set_default()
15 bt->sjw = max(1U, min(bt->phase_seg1, bt->phase_seg2 / 2)); in can_sjw_set_default()
21 if (bt->sjw > btc->sjw_max) { in can_sjw_check()
23 bt->sjw, btc->sjw_max); in can_sjw_check()
24 return -EINVAL; in can_sjw_check()
27 if (bt->sjw > bt->phase_seg1) { in can_sjw_check()
29 "sjw: %u greater than phase-seg1: %u", in can_sjw_check()
30 bt->sjw, bt->phase_seg1); in can_sjw_check()
31 return -EINVAL; in can_sjw_check()
34 if (bt->sjw > bt->phase_seg2) { in can_sjw_check()
36 "sjw: %u greater than phase-seg2: %u", in can_sjw_check()
37 bt->sjw, bt->phase_seg2); in can_sjw_check()
38 return -EINVAL; in can_sjw_check()
44 /* Checks the validity of the specified bit-timing parameters prop_seg,
53 const unsigned int tseg1 = bt->prop_seg + bt->phase_seg1; in can_fixup_bittiming()
58 if (tseg1 < btc->tseg1_min) { in can_fixup_bittiming()
59 NL_SET_ERR_MSG_FMT(extack, "prop-seg + phase-seg1: %u less than tseg1-min: %u", in can_fixup_bittiming()
60 tseg1, btc->tseg1_min); in can_fixup_bittiming()
61 return -EINVAL; in can_fixup_bittiming()
63 if (tseg1 > btc->tseg1_max) { in can_fixup_bittiming()
64 NL_SET_ERR_MSG_FMT(extack, "prop-seg + phase-seg1: %u greater than tseg1-max: %u", in can_fixup_bittiming()
65 tseg1, btc->tseg1_max); in can_fixup_bittiming()
66 return -EINVAL; in can_fixup_bittiming()
68 if (bt->phase_seg2 < btc->tseg2_min) { in can_fixup_bittiming()
69 NL_SET_ERR_MSG_FMT(extack, "phase-seg2: %u less than tseg2-min: %u", in can_fixup_bittiming()
70 bt->phase_seg2, btc->tseg2_min); in can_fixup_bittiming()
71 return -EINVAL; in can_fixup_bittiming()
73 if (bt->phase_seg2 > btc->tseg2_max) { in can_fixup_bittiming()
74 NL_SET_ERR_MSG_FMT(extack, "phase-seg2: %u greater than tseg2-max: %u", in can_fixup_bittiming()
75 bt->phase_seg2, btc->tseg2_max); in can_fixup_bittiming()
76 return -EINVAL; in can_fixup_bittiming()
85 brp64 = (u64)priv->clock.freq * (u64)bt->tq; in can_fixup_bittiming()
86 if (btc->brp_inc > 1) in can_fixup_bittiming()
87 do_div(brp64, btc->brp_inc); in can_fixup_bittiming()
88 brp64 += 500000000UL - 1; in can_fixup_bittiming()
90 if (btc->brp_inc > 1) in can_fixup_bittiming()
91 brp64 *= btc->brp_inc; in can_fixup_bittiming()
92 bt->brp = (u32)brp64; in can_fixup_bittiming()
94 if (bt->brp < btc->brp_min) { in can_fixup_bittiming()
95 NL_SET_ERR_MSG_FMT(extack, "resulting brp: %u less than brp-min: %u", in can_fixup_bittiming()
96 bt->brp, btc->brp_min); in can_fixup_bittiming()
97 return -EINVAL; in can_fixup_bittiming()
99 if (bt->brp > btc->brp_max) { in can_fixup_bittiming()
100 NL_SET_ERR_MSG_FMT(extack, "resulting brp: %u greater than brp-max: %u", in can_fixup_bittiming()
101 bt->brp, btc->brp_max); in can_fixup_bittiming()
102 return -EINVAL; in can_fixup_bittiming()
105 bt->bitrate = priv->clock.freq / (bt->brp * can_bit_time(bt)); in can_fixup_bittiming()
106 bt->sample_point = ((CAN_SYNC_SEG + tseg1) * 1000) / can_bit_time(bt); in can_fixup_bittiming()
107 bt->tq = DIV_U64_ROUND_CLOSEST(mul_u32_u32(bt->brp, NSEC_PER_SEC), in can_fixup_bittiming()
108 priv->clock.freq); in can_fixup_bittiming()
123 if (bt->bitrate == bitrate_const[i]) in can_validate_bitrate()
128 bt->brp); in can_validate_bitrate()
130 return -EINVAL; in can_validate_bitrate()
139 /* Depending on the given can_bittiming parameter structure the CAN in can_get_bittiming()
144 if (!bt->tq && bt->bitrate && btc) in can_get_bittiming()
146 if (bt->tq && !bt->bitrate && btc) in can_get_bittiming()
148 if (!bt->tq && bt->bitrate && bitrate_const) in can_get_bittiming()
152 return -EINVAL; in can_get_bittiming()