All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Kleine-Budde <mkl@pengutronix.de>
To: Oliver Hartkopp <socketcan@hartkopp.net>, linux-can@vger.kernel.org
Subject: Re: [PATCH v5 4/6] can: introduce the data bitrate configuration for CAN FD
Date: Thu, 27 Feb 2014 09:43:12 +0100	[thread overview]
Message-ID: <530EFAA0.4090000@pengutronix.de> (raw)
In-Reply-To: <1393452662-3154-5-git-send-email-socketcan@hartkopp.net>

[-- Attachment #1: Type: text/plain, Size: 2546 bytes --]

On 02/26/2014 11:11 PM, Oliver Hartkopp wrote:
> As CAN FD offers a second bitrate for the data section of the CAN frame the
> infrastructure for storing and configuring this second bitrate is introduced.
> 
> Signed-off-by: Oliver Hartkopp <socketcan@hartkopp.net>
> ---
>  drivers/net/can/dev.c            | 42 +++++++++++++++++++++++++++++++++++++++-
>  include/linux/can/dev.h          |  6 ++++--
>  include/uapi/linux/can/netlink.h |  2 ++
>  3 files changed, 47 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index 368d92d..7887691 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -660,6 +660,10 @@ static const struct nla_policy can_policy[IFLA_CAN_MAX + 1] = {
>  				= { .len = sizeof(struct can_bittiming_const) },
>  	[IFLA_CAN_CLOCK]	= { .len = sizeof(struct can_clock) },
>  	[IFLA_CAN_BERR_COUNTER]	= { .len = sizeof(struct can_berr_counter) },
> +	[IFLA_CAN_DATA_BITTIMING]
> +				= { .len = sizeof(struct can_bittiming) },
> +	[IFLA_CAN_DATA_BITTIMING_CONST]
> +				= { .len = sizeof(struct can_bittiming_const) },
>  };
>  
>  static int can_changelink(struct net_device *dev,
> @@ -693,6 +697,29 @@ static int can_changelink(struct net_device *dev,
>  		}
>  	}
>  
> +	if (data[IFLA_CAN_DATA_BITTIMING]) {
> +		struct can_bittiming bt;
> +
> +		/* Do not allow changing bittiming while running */
> +		if (dev->flags & IFF_UP)
> +			return -EBUSY;
> +		memcpy(&bt, nla_data(data[IFLA_CAN_DATA_BITTIMING]),
> +		       sizeof(bt));
> +		if ((!bt.bitrate && !bt.tq) || (bt.bitrate && bt.tq))
> +			return -EINVAL;
> +		err = can_get_bittiming(dev, &bt, priv->data_bittiming_const);
> +		if (err)
> +			return err;
> +		memcpy(&priv->data_bittiming, &bt, sizeof(bt));
> +
> +		if (priv->do_set_data_bittiming) {
> +			/* Finally, set the bit-timing registers */
> +			err = priv->do_set_data_bittiming(dev);
> +			if (err)
> +				return err;
> +		}

Do we really need the do_set_data_bittiming() callback? Allmost all
drivers set the bitrate during open and not asynchronously (when the
interface is down) via the set_bittiming() callback. If there is a
driver which really needs this callback, we can introduce it.

Marc

-- 
Pengutronix e.K.                  | Marc Kleine-Budde           |
Industrial Linux Solutions        | Phone: +49-231-2826-924     |
Vertretung West/Dortmund          | Fax:   +49-5121-206917-5555 |
Amtsgericht Hildesheim, HRA 2686  | http://www.pengutronix.de   |


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 242 bytes --]

  reply	other threads:[~2014-02-27  9:15 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-02-26 22:10 [PATCH v5 0/6] Add CAN FD infrastructure for CAN driver Oliver Hartkopp
2014-02-26 22:10 ` [PATCH v5 1/6] can: preserve skbuff protocol in can_put_echo_skb Oliver Hartkopp
2014-02-26 22:10 ` [PATCH v5 2/6] can: only send bitrate data via netlink when available Oliver Hartkopp
2014-02-26 22:10 ` [PATCH v5 3/6] can: provide a separate bittiming_const parameter to bittiming functions Oliver Hartkopp
2014-02-26 22:11 ` [PATCH v5 4/6] can: introduce the data bitrate configuration for CAN FD Oliver Hartkopp
2014-02-27  8:43   ` Marc Kleine-Budde [this message]
2014-02-27 18:05     ` Oliver Hartkopp
2014-02-28 10:56       ` Marc Kleine-Budde
2014-02-28 12:20         ` Oliver Hartkopp
2014-02-28 12:30           ` Marc Kleine-Budde
2014-02-28 12:33             ` Oliver Hartkopp
2014-02-28 12:52               ` Marc Kleine-Budde
2014-02-28 12:58                 ` Oliver Hartkopp
2014-02-28 13:05                   ` Marc Kleine-Budde
2014-02-28 13:09                     ` Oliver Hartkopp
2014-02-28 13:18                       ` Marc Kleine-Budde
2014-03-04 20:44                     ` Marc Kleine-Budde
2014-02-26 22:11 ` [PATCH v5 5/6] can: allow to change the device mtu for CAN FD capable devices Oliver Hartkopp
2014-02-26 22:11 ` [PATCH v5 6/6] can: add bittiming check at interface open for CAN FD Oliver Hartkopp

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=530EFAA0.4090000@pengutronix.de \
    --to=mkl@pengutronix.de \
    --cc=linux-can@vger.kernel.org \
    --cc=socketcan@hartkopp.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.