lkml.org 
[lkml]   [2021]   [Oct]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH net-next 6/6] net: dsa: sja1105: parse {rx,tx}-internal-delay-ps properties for RGMII delays
Some take it or leave it comments, checkpatch pointed out some extra
brackets so I had a look at the patch.

On Thu, 14 Oct 2021 01:23:13 +0300 Vladimir Oltean wrote:
> + int rx_delay = -1, tx_delay = -1;
>
> + if (!phy_interface_mode_is_rgmii(phy_mode))
> + return 0;
>
> + of_property_read_u32(port_dn, "rx-internal-delay-ps", &rx_delay);
> + of_property_read_u32(port_dn, "tx-internal-delay-ps", &tx_delay);

If I'm reading this right you're depending on delays being left as -1
in case the property reads fail. Is this commonly accepted practice?
Why not code it up as:

u32 rx_delay;

if (of_property_read_u32(...))
rx_delay = 0;
else if (rx_delay != clamp(rx_delay, ...MIN, ...MAX)
goto err;

or some such?

> + if ((rx_delay && rx_delay < SJA1105_RGMII_DELAY_MIN_PS) ||
> + (tx_delay && tx_delay < SJA1105_RGMII_DELAY_MIN_PS) ||
> + (rx_delay > SJA1105_RGMII_DELAY_MAX_PS) ||
> + (tx_delay > SJA1105_RGMII_DELAY_MAX_PS)) {

nit: checkpatch says the brackets around the latter two are unnecessary,
just in case it's not for symmetry / on purpose

\
 
 \ /
  Last update: 2021-10-14 02:25    [W:0.132 / U:0.452 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site