]> git.karo-electronics.de Git - linux-beck.git/commitdiff
can: add bittiming check at interface open for CAN FD
authorOliver Hartkopp <socketcan@hartkopp.net>
Fri, 28 Feb 2014 15:36:25 +0000 (16:36 +0100)
committerMarc Kleine-Budde <mkl@pengutronix.de>
Fri, 7 Mar 2014 08:18:23 +0000 (09:18 +0100)
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>
drivers/net/can/dev.c

index 4e20d82b799e4e7b35d8b524af4ed748963faba9..c7a260478749ad163ec133df88e7a0086b220a73 100644 (file)
@@ -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);