Re: [PATCH 2/5] can: bittiming: can_calc_bittiming(): make use of min3()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 01.02.2023 14:49:23, Vincent Mailhol wrote:
> > I've converted the existing netdev_err() NL_SET_ERR_MSG_FMT(). This
> > means the error message is transported via netlink to user space and
> > printed by the "ip" tool.
> 
> I was not aware of this NL_SET_ERR_MSG_FMT() thing, and let me say
> that I really like that solution!
> 
> > | # ip link set flexcan0 txqueuelen 10 type can bitrate 2200000
> > | Warning: bitrate error 2.5%.
> 
> The Linux coding style says:
> 
>   Kernel messages do not have to be terminated with a period.
> 
> Ref: https://www.kernel.org/doc/html/latest/process/coding-style.html#printing-kernel-messages
> 
> However, I am not sure if this also applies to the ip tool.

I think the period is added by "ip".

> > |
> > | # ip link set flexcan0 txqueuelen 10 type can bitrate 22000000
> > | Error: bitrate error 80.5% too high.
> >
> > This is the error message for the SJW check:
> >
> > | # ip link set flexcan0 txqueuelen 10 type can bitrate 500000 sjw 3
> > | Error: SJW 3 bigger than phase_seg1 6 and/or phase_seg2 2.
> 
> At that point in the code, I assume that sjw was already validated
> against sjw_max. While not impossible, I think that having sjw bigger
> than both phase_seg1 and phase_seg2 at the same time is uncommon. I
> suggest to split the error message in two and only print the relevant
> one:
> 
>   Error: SJW 3 bigger than phase_seg1 x
>   Error: SJW 3 bigger than phase_seg2 x
> 
> If the user still manages to violate both, only the phase_seg1 error
> message is displayed.

Makes sense.

> > Maybe add a '=' between the phase_seg and the actual number:
> >
> > | Error: SJW 3 bigger than phase_seg1=6 and/or phase_seg2=2.
> 
> If you ask me my preferences, I will go with column:
> 
>   Error: SJW: 3 bigger than phase_seg1: 6 and/or phase_seg2: 2.
> 
> But I will not complain if you pick anything else.

Period looks good.

What about the error value? Always return -EINVAL instead of a mix of
-EINVAL and -ERANGE?

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Attachment: signature.asc
Description: PGP signature


[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux