[PATCH v4 2/2] ethernet: eswin: Add eic7700 ethernet driver
Andrew Lunn
andrew at lunn.ch
Wed Aug 27 05:37:14 PDT 2025
> +/**
> + * eic7700_apply_delay - Update TX or RX delay bits in delay parameter value.
> + * @delay_ps: Delay in picoseconds (capped at 12.7ns).
> + * @reg: Pointer to register value to modify.
> + * @is_rx: True for RX delay (bits 30:24), false for TX delay (bits 14:8).
> + *
> + * Converts delay to 0.1ns units, caps at 0x7F, and sets appropriate bits.
> + * Only RX or TX bits are updated; other bits remain unchanged.
> + */
> +static inline void eic7700_apply_delay(u32 delay_ps, u32 *reg, bool is_rx)
> +{
> + if (!reg)
> + return;
> +
Please don't use inline functions in .c files. Leave the compile to
decide.
> + /* Read rx-internal-delay-ps and update rx_clk delay */
> + if (!of_property_read_u32(pdev->dev.of_node,
> + "rx-internal-delay-ps",
> + &dwc_priv->rx_delay_ps)) {
> + eic7700_apply_delay(dwc_priv->rx_delay_ps,
> + ð_dly_param, true);
> + } else {
> + dev_warn(&pdev->dev, "can't get rx-internal-delay-ps\n");
> + }
> +
> + /* Read tx-internal-delay-ps and update tx_clk delay */
> + if (!of_property_read_u32(pdev->dev.of_node,
> + "tx-internal-delay-ps",
> + &dwc_priv->tx_delay_ps)) {
> + eic7700_apply_delay(dwc_priv->tx_delay_ps,
> + ð_dly_param, false);
Given this code, why does eic7700_apply_delay() test for reg? Don't
use defensive code, read your own code and make sure it cannot happen.
Andrew
---
pw-bot: cr
More information about the linux-arm-kernel
mailing list