From: Oliver Hartkopp <socketcan@hartkopp.net>
To: Vincent MAILHOL <mailhol.vincent@wanadoo.fr>
Cc: Marc Kleine-Budde <mkl@pengutronix.de>,
linux-can@vger.kernel.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, Jimmy Assarsson <extja@kvaser.com>
Subject: Re: [PATCH] can: bittiming: replace CAN units with the SI metric
Date: Tue, 23 Nov 2021 21:53:28 +0100 [thread overview]
Message-ID: <73c3b9cb-3b46-1523-d926-4bdf86de3fb8@hartkopp.net> (raw)
In-Reply-To: <CAMZ6RqJobmUnAMUjnaqYh0jsOPw7-PwiF+bF79hy6h+8SCuuDg@mail.gmail.com>
Hi Vincent,
On 22.11.21 03:22, Vincent MAILHOL wrote:
> Le lun. 22 nov. 2021 à 03:27, Oliver Hartkopp <socketcan@hartkopp.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?
Best regards,
Oliver
next prev parent reply other threads:[~2021-11-23 20:56 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-11-19 16:18 Vincent Mailhol
2021-11-21 18:27 ` Oliver Hartkopp
2021-11-22 2:22 ` Vincent MAILHOL
2021-11-23 7:44 ` Jimmy Assarsson
2021-11-23 20:53 ` Oliver Hartkopp [this message]
2021-11-23 23:26 ` 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=73c3b9cb-3b46-1523-d926-4bdf86de3fb8@hartkopp.net \
--to=socketcan@hartkopp.net \
--cc=extja@kvaser.com \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mailhol.vincent@wanadoo.fr \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.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
all inboxes | Powered by JetHome®