summaryrefslogtreecommitdiffstats
path: root/drivers/net/can
diff options
context:
space:
mode:
authorOliver Hartkopp <socketcan@hartkopp.net>2014-02-28 16:36:25 +0100
committerMarc Kleine-Budde <mkl@pengutronix.de>2014-03-07 09:18:23 +0100
commitdd22586dec4c1444608affd83b1fedd520280ab4 (patch)
treea601282c8394c86b5df68ffb8682526ec6f01ee7 /drivers/net/can
parentbc05a8944a344acdb81a65de055ca6febbf9657c (diff)
downloadlinux-dd22586dec4c1444608affd83b1fedd520280ab4.tar.bz2
can: add bittiming check at interface open for CAN FD
Additionally to have the second (data) bitrate available the data bitrate has to be greater or equal to the arbitration bitrate in CAN FD. Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net> Acked-by: Stephane Grosjean <s.grosjean@peak-system.com> Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
Diffstat (limited to 'drivers/net/can')
-rw-r--r--drivers/net/can/dev.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 4e20d82b799e..c7a260478749 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -642,6 +642,14 @@ int open_candev(struct net_device *dev)
return -EINVAL;
}
+ /* For CAN FD the data bitrate has to be >= the arbitration bitrate */
+ if ((priv->ctrlmode & CAN_CTRLMODE_FD) &&
+ (!priv->data_bittiming.bitrate ||
+ (priv->data_bittiming.bitrate < priv->bittiming.bitrate))) {
+ netdev_err(dev, "incorrect/missing data bit-timing\n");
+ return -EINVAL;
+ }
+
/* Switch carrier on if device was stopped while in bus-off state */
if (!netif_carrier_ok(dev))
netif_carrier_on(dev);