Skip to contentSkip to conversation

net: stmmac: eic7700: Use syscon_regmap_lookup_by_phandle_args

PATCH Applied Krzysztof Kozlowski 4 participants 4 messages Nov 21 – Nov 25

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: stmmac: eic7700: Use syscon_regmap_lookup_by_phandle_args

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.

---
 .../ethernet/stmicro/stmmac/dwmac-eic7700.c   | 30 +++++--------------
 1 file changed, 8 insertions(+), 22 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-eic7700.c +8 -22
index c229275b11b3..287f717ab3ed 100644
@@ -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",
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines

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.

Quoted 8 lines

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.

Quoted 61 lines
---
 .../ethernet/stmicro/stmmac/dwmac-eic7700.c   | 30 +++++--------------
 1 file changed, 8 insertions(+), 22 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-eic7700.c +8 -22
index c229275b11b3..287f717ab3ed 100644
@@ -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",
Signature · 1 line
2.53.0
maintainer Reviewed-by on v1 1/1
#2 lore raw
In reply to Krzysztof Kozlowski
Quoted 5 lines · Krzysztof Kozlowski

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.

Quoted 8 lines

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.

Thank you,

Maxime

Quoted 57 lines
---
 .../ethernet/stmicro/stmmac/dwmac-eic7700.c   | 30 +++++--------------
 1 file changed, 8 insertions(+), 22 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-eic7700.c +8 -22
index c229275b11b3..287f717ab3ed 100644
@@ -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",
#3 lore raw
In reply to Krzysztof Kozlowski
This patch was applied to netdev/net-next.git (main) by Willem de Bruijn <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Willem de Bruijn <[email protected]>:

Quoted 5 lines · On Sat, 21 Nov 2026 18:07:54 +0100 you wrote:

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.

Quoted 8 lines

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.

[...]

Here is the summary with links:
- [net-next] net: stmmac: eic7700: Use syscon_regmap_lookup_by_phandle_args

    https://git.kernel.org/netdev/net-next/c/882f4ba39863

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html