lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAMZ6RqKiy0FXa0RLhAeG+=R37WhFAmLamXCJM_T1f7TaSrs-gw@mail.gmail.com>
Date:   Wed, 24 Nov 2021 08:26:37 +0900
From:   Vincent MAILHOL <mailhol.vincent@...adoo.fr>
To:     Oliver Hartkopp <socketcan@...tkopp.net>
Cc:     Marc Kleine-Budde <mkl@...gutronix.de>, linux-can@...r.kernel.org,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
        Jimmy Assarsson <extja@...ser.com>
Subject: Re: [PATCH] can: bittiming: replace CAN units with the SI metric

On Wed. 24 Nov. 2021 à 05:53, Oliver Hartkopp <socketcan@...tkopp.net> wrote:
> Hi Vincent,
> On 22.11.21 03:22, Vincent MAILHOL wrote:
> > Le lun. 22 nov. 2021 à 03:27, Oliver Hartkopp <socketcan@...tkopp.net> a écrit :
>
>
> >>>    #include <linux/kernel.h>
> >>> +#include <linux/units.h>
> >>>    #include <asm/unaligned.h>
> >>>
> >>>    #include "es58x_core.h"
> >>> @@ -469,8 +470,8 @@ const struct es58x_parameters es581_4_param = {
> >>>        .bittiming_const = &es581_4_bittiming_const,
> >>>        .data_bittiming_const = NULL,
> >>>        .tdc_const = NULL,
> >>> -     .bitrate_max = 1 * CAN_MBPS,
> >>> -     .clock = {.freq = 50 * CAN_MHZ},
> >>> +     .bitrate_max = 1 * MEGA,
> >>> +     .clock = {.freq = 50 * MEGA},
> >>
> >> IMO we are losing information here.
> >>
> >> It feels you suggest to replace MHz with M.
> >
> > When I introduced the CAN_{K,M}BPS and CAN_MHZ macros, my primary
> > intent was to avoid having to write more than five zeros in a
> > row (because the human brain is bad at counting those). And the
> > KILO/MEGA prefixes perfectly cover that intent.
> >
> > You are correct to say that the information of the unit is
> > lost. But I assume this information to be implicit (frequencies
> > are in Hz, baudrate are in bits/second). So yes, I suggest
> > replacing MHz with M.
> >
> > Do you really think that people will be confused by this change?
>
> It is not about confusing people but about the quality of documentation
> and readability.
>
> >
> > I am not strongly opposed to keeping it either (hey, I was the
> > one who introduced it in the first place). I just think that
> > using linux/units.h is sufficient.
> >
> >> So where is the Hz information then?
> >
> > It is in the comment of can_clock:freq :)
> >
> > https://elixir.bootlin.com/linux/v5.15/source/include/uapi/linux/can/netlink.h#L63
>
> Haha, you are funny ;-)
>
> But the fact that you provide this URL shows that the information is not
> found or easily accessible when someone reads the code here.
>
> >>> -     .bitrate_max = 8 * CAN_MBPS,
> >>> -     .clock = {.freq = 80 * CAN_MHZ},
> >>> +     .bitrate_max = 8 * MEGA,
> >>> +     .clock = {.freq = 80 * MEGA},
>
> What about
>
> +     .bitrate_max = 8 * MEGA, /* bits per second */
> +     .clock = {.freq = 80 * MEGA}, /* Hz */
>
> which uses the SI constants but maintains the unit?

This works with. Actually, I also hesitated to add such comments
when writing this patch. For the sake of the quality of the
documentation, I will prepare a v2.


Yours sincerely,
Vincent Mailhol

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ