linux-can.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Oliver Hartkopp <socketcan@hartkopp.net>
To: linux-can@vger.kernel.org
Cc: Oliver Hartkopp <socketcan@hartkopp.net>
Subject: [PATCH v7 7/7] can: add bittiming check at interface open for CAN FD
Date: Fri, 28 Feb 2014 11:26:28 +0100	[thread overview]
Message-ID: <1393583188-13307-8-git-send-email-socketcan@hartkopp.net> (raw)
In-Reply-To: <1393583188-13307-1-git-send-email-socketcan@hartkopp.net>

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>
---
 drivers/net/can/dev.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index f2825b4..05b5dc2 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -643,6 +643,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);
-- 
1.9.0


      parent reply	other threads:[~2014-02-28 10:26 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-28 10:26 [PATCH v7 0/7] Add CAN FD infrastructure for CAN driver Oliver Hartkopp
2014-02-28 10:26 ` [PATCH v7 1/7] can: preserve skbuff protocol in can_put_echo_skb Oliver Hartkopp
2014-02-28 10:26 ` [PATCH v7 2/7] can: only send bitrate data via netlink when available Oliver Hartkopp
2014-02-28 10:26 ` [PATCH v7 3/7] can: move sanity check for bitrate and tq into can_get_bittiming Oliver Hartkopp
2014-02-28 10:26 ` [PATCH v7 4/7] can: provide a separate bittiming_const parameter to bittiming functions Oliver Hartkopp
2014-02-28 10:46   ` Marc Kleine-Budde
2014-02-28 12:31     ` Oliver Hartkopp
2014-02-28 13:02       ` Marc Kleine-Budde
2014-02-28 13:07         ` Oliver Hartkopp
2014-02-28 10:26 ` [PATCH v7 5/7] can: introduce the data bitrate configuration for CAN FD Oliver Hartkopp
2014-02-28 10:26 ` [PATCH v7 6/7] can: allow to change the device mtu for CAN FD capable devices Oliver Hartkopp
2014-02-28 10:26 ` Oliver Hartkopp [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1393583188-13307-8-git-send-email-socketcan@hartkopp.net \
    --to=socketcan@hartkopp.net \
    --cc=linux-can@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).