aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorOliver Hartkopp <socketcan@hartkopp.net>2011-09-27 22:50:11 -0400
committerDavid S. Miller <davem@davemloft.net>2011-09-28 13:41:51 -0400
commit2e1143742789463c00ed5e7f9bf471f2b707b493 (patch)
treee0b3aa72bccbbf8aa5e5236a5c310c6ee4eaeef3 /drivers/net/can
parentd4fa0e35fdbd54acf791fa3793d6d17f7795f7ae (diff)
candev: allow SJW user setting for bittiming calculation
This patch adds support for SJW user settings to not set the synchronization jump width (SJW) to 1 in any case when using the in-kernel bittiming calculation. The ip-tool from iproute2 already supports to pass the user defined SJW value. The given SJW value is sanitized with the controller specific sjw_max and the calculated tseg2 value. As the SJW can have values up to 4 providing this value will lead to the maximum possible SJW automatically. A higher SJW allows higher controller oscillator tolerances. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Acked-by: Wolfgang Grandegger <wg@grandegger.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/dev.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 9bf1116e5b5e..25695bde0549 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -150,7 +150,19 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt)
150 bt->prop_seg = tseg1 / 2; 150 bt->prop_seg = tseg1 / 2;
151 bt->phase_seg1 = tseg1 - bt->prop_seg; 151 bt->phase_seg1 = tseg1 - bt->prop_seg;
152 bt->phase_seg2 = tseg2; 152 bt->phase_seg2 = tseg2;
153 bt->sjw = 1; 153
154 /* check for sjw user settings */
155 if (!bt->sjw || !btc->sjw_max)
156 bt->sjw = 1;
157 else {
158 /* bt->sjw is at least 1 -> sanitize upper bound to sjw_max */
159 if (bt->sjw > btc->sjw_max)
160 bt->sjw = btc->sjw_max;
161 /* bt->sjw must not be higher than tseg2 */
162 if (tseg2 < bt->sjw)
163 bt->sjw = tseg2;
164 }
165
154 bt->brp = best_brp; 166 bt->brp = best_brp;
155 /* real bit-rate */ 167 /* real bit-rate */
156 bt->bitrate = priv->clock.freq / (bt->brp * (tseg1 + tseg2 + 1)); 168 bt->bitrate = priv->clock.freq / (bt->brp * (tseg1 + tseg2 + 1));