From: Wolfgang Grandegger <wg-5Yr1BZd7O62+XT7JhA+gdA@public.gmane.org>
To: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
Cc: SocketCAN Core Mailing List
<socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org>,
Linux Netdev List
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
Píša@mail.berlios.de,
David Miller <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
Pavel-XecQL68PM4x789tOGE2Ojw@public.gmane.org
Subject: Re: [PATCH net-next] candev: allow SJW user setting for bittiming calculation
Date: Thu, 22 Sep 2011 13:00:19 +0200 [thread overview]
Message-ID: <4E7B1543.2000603@grandegger.com> (raw)
In-Reply-To: <4E7B0CE4.3070402-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
Hi Oliver,
On 09/22/2011 12:24 PM, Oliver Hartkopp wrote:
> This patch adds support for SJW user settings to not set the synchronization
> jump width (SJW) to 1 in any case when using the in-kernel bittiming
> calculation.
>
> The ip-tool from iproute2 already supports to pass the user defined SJW
> value. The given SJW value is sanitized with the controller specific sjw_max
> and the calculated tseg2 value. As the SJW can have values up to 4 providing
> this value will lead to the maximum possible SJW automatically. A higher SJW
> allows higher controller oscillator tolerances.
>
> Signed-off-by: Oliver Hartkopp <socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
>
> ---
>
> diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
> index 9bf1116..25695bd 100644
> --- a/drivers/net/can/dev.c
> +++ b/drivers/net/can/dev.c
> @@ -150,7 +150,19 @@ static int can_calc_bittiming(struct net_device *dev, struct can_bittiming *bt)
> bt->prop_seg = tseg1 / 2;
> bt->phase_seg1 = tseg1 - bt->prop_seg;
> bt->phase_seg2 = tseg2;
> - bt->sjw = 1;
> +
> + /* check for sjw user settings */
> + if (!bt->sjw || !btc->sjw_max)
> + bt->sjw = 1;
> + else {
> + /* bt->sjw is at least 1 -> sanitize upper bound to sjw_max */
> + if (bt->sjw > btc->sjw_max)
> + bt->sjw = btc->sjw_max;
> + /* bt->sjw must not be higher than tseg2 */
> + if (tseg2 < bt->sjw)
> + bt->sjw = tseg2;
> + }
> +
Hm, bt->sjw is always 0 when can_calc_bittiming() is called!? Or have I
missed something.
Wolfgang,
prev parent reply other threads:[~2011-09-22 11:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-09-22 10:24 [PATCH net-next] candev: allow SJW user setting for bittiming calculation Oliver Hartkopp
[not found] ` <4E7B0CE4.3070402-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.org>
2011-09-22 11:00 ` Wolfgang Grandegger [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=4E7B1543.2000603@grandegger.com \
--to=wg-5yr1bzd7o62+xt7jha+gda@public.gmane.org \
--cc=Pavel-XecQL68PM4x789tOGE2Ojw@public.gmane.org \
--cc=Píša@mail.berlios.de \
--cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=socketcan-core-0fE9KPoRgkgATYTw5x5z8w@public.gmane.org \
--cc=socketcan-fJ+pQTUTwRTk1uMJSBkQmQ@public.gmane.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).