All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
To: Marc Kleine-Budde <mkl@pengutronix.de>,
	Stephen Hemminger <stephen@networkplumber.org>,
	linux-can@vger.kernel.org
Cc: "Stefan Mätje" <stefan.maetje@esd.eu>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Vincent Mailhol" <mailhol.vincent@wanadoo.fr>
Subject: [PATCH v5 3/4] iplink_can: print brp and dbrp bittiming variables
Date: Sat, 14 Aug 2021 19:17:27 +0900	[thread overview]
Message-ID: <20210814101728.75334-4-mailhol.vincent@wanadoo.fr> (raw)
In-Reply-To: <20210814101728.75334-1-mailhol.vincent@wanadoo.fr>

Report the value of the bit-rate prescaler (brp) for both the nominal
and the data bittiming.

Currently, only the constant brp values (brp_{min,max,inc}) are being
reported. Also, brp is the only member of struct can_bittiming not
being reported.

Noticeably, brp is not used as an input for bittiming calculation and
although it could be calculated by hand from the other bittiming
parameters with below formula:

        brp = clock * tq / 1000000000

with clock in hertz and tq in nano second (thus the need of a 1
billion factor to convert it back to second).

But because above formula is not so trivial to remember and is
subjected to rounding errors, it makes sense to directly output
{d,}bpr.

Signed-off-by: Vincent Mailhol <mailhol.vincent@wanadoo.fr>
---
 ip/iplink_can.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/ip/iplink_can.c b/ip/iplink_can.c
index 52ba3d12..e438e416 100644
--- a/ip/iplink_can.c
+++ b/ip/iplink_can.c
@@ -336,6 +336,7 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		print_uint(PRINT_ANY, "phase_seg2", " phase-seg2 %u",
 			   bt->phase_seg2);
 		print_uint(PRINT_ANY, "sjw", " sjw %u", bt->sjw);
+		print_uint(PRINT_ANY, "brp", " brp %u", bt->brp);
 		close_json_object();
 	}
 
@@ -411,6 +412,7 @@ static void can_print_opt(struct link_util *lu, FILE *f, struct rtattr *tb[])
 		print_uint(PRINT_ANY, "phase_seg2", " dphase-seg2 %u",
 			   dbt->phase_seg2);
 		print_uint(PRINT_ANY, "sjw", " dsjw %u", dbt->sjw);
+		print_uint(PRINT_ANY, "brp", " dbrp %u", dbt->brp);
 		close_json_object();
 	}
 
-- 
2.31.1


  parent reply	other threads:[~2021-08-14 10:18 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-14 10:17 [PATCH v5 0/4] iplink_can: cleaning, fixes and adding TDC support Vincent Mailhol
2021-08-14 10:17 ` [PATCH v5 1/4] iplink_can: fix configuration ranges in print_usage() and add unit Vincent Mailhol
2021-08-14 10:17 ` [PATCH v5 2/4] iplink_can: use PRINT_ANY to factorize code and fix signedness Vincent Mailhol
2021-08-14 10:17 ` Vincent Mailhol [this message]
2021-08-14 10:17 ` [PATCH v5 4/4] iplink_can: add new CAN FD bittiming parameters: Transmitter Delay Compensation (TDC) Vincent Mailhol
2021-08-14 11:14   ` Marc Kleine-Budde
2021-08-16 11:02     ` Vincent MAILHOL
2021-08-16  8:12   ` Marc Kleine-Budde
2021-08-16 10:40     ` Vincent MAILHOL
2021-08-16 13:51   ` Marc Kleine-Budde
2021-08-16 16:24     ` Vincent MAILHOL
2021-08-16 23:59       ` Vincent MAILHOL

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=20210814101728.75334-4-mailhol.vincent@wanadoo.fr \
    --to=mailhol.vincent@wanadoo.fr \
    --cc=linux-can@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mkl@pengutronix.de \
    --cc=netdev@vger.kernel.org \
    --cc=stefan.maetje@esd.eu \
    --cc=stephen@networkplumber.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 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.