]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
iplink_can: print brp and dbrp bittiming variables
authorVincent Mailhol <mailhol.vincent@wanadoo.fr>
Wed, 3 Nov 2021 16:44:27 +0000 (01:44 +0900)
committerDavid Ahern <dsahern@kernel.org>
Thu, 4 Nov 2021 15:42:54 +0000 (09:42 -0600)
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 <mailhol.vincent@wanadoo.fr>
Signed-off-by: David Ahern <dsahern@kernel.org>
ip/iplink_can.c

index c016523793afdd719de1893f1a9b8281a9217489..cf6b06b89a9943b1592bb26ad2d46f24a8fb7649 100644 (file)
@@ -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();
        }