Re: [PATCH net-next] net: stmmac: eic7700: Use syscon_regmap_lookup_by_phandle_args
From: Lorenzo Bianconi
Date: Sat Nov 21 2026 - 12:20:21 EST
> Use syscon_regmap_lookup_by_phandle_args() which is a wrapper over
> syscon_regmap_lookup_by_phandle() combined with getting the syscon
> argument. Except simpler code this annotates within one line that given
> phandle has arguments, so grepping for code would be easier.
>
> There is also no real benefit in printing errors of missing individual
> syscon arguments, because this is done just too late: runtime check on
> static/build-time data. Dtschema and Devicetree bindings offer the
> static/build-time check for this already. OTOH,
> syscon_regmap_lookup_by_phandle_args() already handles error case if the
> number of arguments is too low, thus switch is safe.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxxxxx>
Reviewed-by: Lorenzo Bianconi <lorenzo.bianconi@xxxxxxxxxxxxxxxx>
> ---
> .../ethernet/stmicro/stmmac/dwmac-eic7700.c | 30 +++++--------------
> 1 file changed, 8 insertions(+), 22 deletions(-)
>
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-eic7700.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-eic7700.c
> index c229275b11b3..287f717ab3ed 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-eic7700.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-eic7700.c
> @@ -170,6 +170,7 @@ static int eic7700_dwmac_probe(struct platform_device *pdev)
> struct plat_stmmacenet_data *plat_dat;
> struct stmmac_resources stmmac_res;
> struct eic7700_qos_priv *dwc_priv;
> + unsigned int hsp_args[3];
> u32 delay_ps, val;
> int i, ret;
>
> @@ -254,33 +255,18 @@ static int eic7700_dwmac_probe(struct platform_device *pdev)
> }
>
> dwc_priv->eic7700_hsp_regmap =
> - syscon_regmap_lookup_by_phandle(pdev->dev.of_node,
> - "eswin,hsp-sp-csr");
> + syscon_regmap_lookup_by_phandle_args(pdev->dev.of_node,
> + "eswin,hsp-sp-csr",
> + ARRAY_SIZE(hsp_args),
> + hsp_args);
> if (IS_ERR(dwc_priv->eic7700_hsp_regmap))
> return dev_err_probe(&pdev->dev,
> PTR_ERR(dwc_priv->eic7700_hsp_regmap),
> "Failed to get hsp-sp-csr regmap\n");
>
> - ret = of_property_read_u32_index(pdev->dev.of_node,
> - "eswin,hsp-sp-csr",
> - 1, &dwc_priv->eth_phy_ctrl_offset);
> - if (ret)
> - return dev_err_probe(&pdev->dev, ret,
> - "can't get eth_phy_ctrl_offset\n");
> -
> - ret = of_property_read_u32_index(pdev->dev.of_node,
> - "eswin,hsp-sp-csr",
> - 2, &dwc_priv->eth_axi_lp_ctrl_offset);
> - if (ret)
> - return dev_err_probe(&pdev->dev, ret,
> - "can't get eth_axi_lp_ctrl_offset\n");
> -
> - ret = of_property_read_u32_index(pdev->dev.of_node,
> - "eswin,hsp-sp-csr",
> - 3, &dwc_priv->eth_clk_offset);
> - if (ret)
> - return dev_err_probe(&pdev->dev, ret,
> - "can't get eth_clk_offset\n");
> + dwc_priv->eth_phy_ctrl_offset = hsp_args[0];
> + dwc_priv->eth_axi_lp_ctrl_offset = hsp_args[1];
> + dwc_priv->eth_clk_offset = hsp_args[2];
>
> ret = of_property_read_u32_index(pdev->dev.of_node,
> "eswin,hsp-sp-csr",
> --
> 2.53.0
>
>
Attachment:
signature.asc
Description: PGP signature