From patchwork Wed Nov 3 16:44:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vincent Mailhol X-Patchwork-Id: 12601209 X-Patchwork-Delegate: dsahern@gmail.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ABEEAC433EF for ; Wed, 3 Nov 2021 16:45:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9277C61101 for ; Wed, 3 Nov 2021 16:45:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232950AbhKCQsB (ORCPT ); Wed, 3 Nov 2021 12:48:01 -0400 Received: from smtp04.smtpout.orange.fr ([80.12.242.126]:52248 "EHLO smtp.smtpout.orange.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232972AbhKCQsA (ORCPT ); Wed, 3 Nov 2021 12:48:00 -0400 Received: from tomoyo.flets-east.jp ([114.149.34.46]) by smtp.orange.fr with ESMTPA id iJNLmc3ywk3HQiJO4msN4F; Wed, 03 Nov 2021 17:45:22 +0100 X-ME-Helo: tomoyo.flets-east.jp X-ME-Auth: MDU0YmViZGZmMDIzYiBlMiM2NTczNTRjNWZkZTMwOGRiOGQ4ODf3NWI1ZTMyMzdiODlhOQ== X-ME-Date: Wed, 03 Nov 2021 17:45:22 +0100 X-ME-IP: 114.149.34.46 From: Vincent Mailhol To: David Ahern , Stephen Hemminger Cc: Marc Kleine-Budde , netdev@vger.kernel.org, linux-can@vger.kernel.org, Vincent Mailhol Subject: [PATCH iproute2-next 5.16 v6 4/5] iplink_can: print brp and dbrp bittiming variables Date: Thu, 4 Nov 2021 01:44:27 +0900 Message-Id: <20211103164428.692722-5-mailhol.vincent@wanadoo.fr> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211103164428.692722-1-mailhol.vincent@wanadoo.fr> References: <20211103164428.692722-1-mailhol.vincent@wanadoo.fr> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: dsahern@gmail.com 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 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 --- ip/iplink_can.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ip/iplink_can.c b/ip/iplink_can.c index c0165237..cf6b06b8 100644 --- a/ip/iplink_can.c +++ b/ip/iplink_can.c @@ -344,6 +344,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(); } @@ -419,6 +420,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(); }