From: Oliver Hartkopp Date: Fri, 28 Feb 2014 15:36:25 +0000 (+0100) Subject: can: add bittiming check at interface open for CAN FD X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=dd22586dec4c1444608affd83b1fedd520280ab4;p=linux-beck.git 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 Acked-by: Stephane Grosjean Signed-off-by: Marc Kleine-Budde --- 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);