Skip to contentSkip to conversation

net: stmmac: dwmac-qcom-ethqos: Improve error handling

PATCH Applied Andrew Halaney 3 participants 7 messages Jul 10, 2023 – Jul 12, 2023

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

v2 cover net: stmmac: dwmac-qcom-ethqos: Improve error handling

This series includes some very minor quality of life patches in the error handling.

I recently ran into a few issues where these patches would have made my life easier (messing with the devicetree, dependent driver of this failing, and incorrect kernel configs resulting in this driver not probing).

v1: https://lore.kernel.org/netdev/[email protected]/
Changes since v1:
* Collect tags (Andrew Lunn)
* Switch to of_get_phy_mode() (Andrew Lunn)
* Follow netdev patch submission process (net-next subject, wait until merge window is open) (Simon)

Andrew Halaney (3):
net: stmmac: dwmac-qcom-ethqos: Use of_get_phy_mode() over
device_get_phy_mode()
net: stmmac: dwmac-qcom-ethqos: Use dev_err_probe()
net: stmmac: dwmac-qcom-ethqos: Log more errors in probe

 .../stmicro/stmmac/dwmac-qcom-ethqos.c        | 28 +++++++++++--------
 1 file changed, 17 insertions(+), 11 deletions(-)
Signature · 1 line
2.41.0
#1 lore raw

PATCH v2 1/3 net: stmmac: dwmac-qcom-ethqos: Use of_get_phy_mode() over device_get_phy_mode()

Since this driver only uses devicetree, let's move over to of_get_phy_mode(). That API has an explicit error return and produces a phy_interface_t directly instead of an int when representing the phy mode.

---

Changes since v1:
* Convert to using of_get_phy_mode() instead of continuing to use device_get_phy_mode() (Andrew Lunn)

 .../net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c    | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +5 -5
index e62940414e54..ebafdadb28d5 100644
@@ -4,10 +4,10 @@
 #include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
+#include <linux/of_net.h>
 #include <linux/platform_device.h>
 #include <linux/phy.h>
 #include <linux/phy/phy.h>
-#include <linux/property.h>
 
 #include "stmmac.h"
 #include "stmmac_platform.h"
@@ -104,7 +104,7 @@ struct qcom_ethqos {
 	struct clk *link_clk;
 	struct phy *serdes_phy;
 	unsigned int speed;
-	int phy_mode;
+	phy_interface_t phy_mode;
 
 	const struct ethqos_emac_por *por;
 	unsigned int num_por;
@@ -720,7 +720,9 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 	if (!ethqos)
 		return -ENOMEM;
 
-	ethqos->phy_mode = device_get_phy_mode(dev);
+	ret = of_get_phy_mode(np, &ethqos->phy_mode);
+	if (ret)
+		return dev_err_probe(dev, ret, "Failed to get phy mode\n");
 	switch (ethqos->phy_mode) {
 	case PHY_INTERFACE_MODE_RGMII:
 	case PHY_INTERFACE_MODE_RGMII_ID:
@@ -731,8 +733,6 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 	case PHY_INTERFACE_MODE_SGMII:
 		ethqos->configure_func = ethqos_configure_sgmii;
 		break;
-	case -ENODEV:
-		return -ENODEV;
 	default:
 		return -EINVAL;
 	}
Signature · 1 line
2.41.0
Reviewed-by on v2 1/3
#2 lore raw

Re: [PATCH net-next v2 1/3] net: stmmac: dwmac-qcom-ethqos: Use of_get_phy_mode() over device_get_phy_mode()

Quoted 6 lines · Andrew Halaney

Since this driver only uses devicetree, let's move over to of_get_phy_mode(). That API has an explicit error return and produces a phy_interface_t directly instead of an int when representing the phy mode.

Andrew

#3 lore raw

PATCH v2 2/3 net: stmmac: dwmac-qcom-ethqos: Use dev_err_probe()

In reply to Andrew Halaney

Using dev_err_probe() logs to devices_deferred which is helpful when debugging.

---

Changes since v1:
* Collect tags (Andrew Lunn)

 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +2 -2
index ebafdadb28d5..1e103fd356b7 100644
@@ -710,8 +710,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 
 	plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
 	if (IS_ERR(plat_dat)) {
-		dev_err(dev, "dt configuration failed\n");
-		return PTR_ERR(plat_dat);
+		return dev_err_probe(dev, PTR_ERR(plat_dat),
+				     "dt configuration failed\n");
 	}
 
 	plat_dat->clks_config = ethqos_clks_config;
Signature · 1 line
2.41.0
#4 lore raw

PATCH v2 3/3 net: stmmac: dwmac-qcom-ethqos: Log more errors in probe

In reply to Andrew Halaney

These are useful to see when debugging a probe failure.

---

Changes since v1:
* No changes

 .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c    | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c +10 -4
index 1e103fd356b7..757504ebb676 100644
@@ -706,7 +706,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 
 	ret = stmmac_get_platform_resources(pdev, &stmmac_res);
 	if (ret)
-		return ret;
+		return dev_err_probe(dev, ret,
+				     "Failed to get platform resources\n");
 
 	plat_dat = devm_stmmac_probe_config_dt(pdev, stmmac_res.mac);
 	if (IS_ERR(plat_dat)) {
@@ -734,13 +735,16 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 		ethqos->configure_func = ethqos_configure_sgmii;
 		break;
 	default:
+		dev_err(dev, "Unsupported phy mode %s\n",
+			phy_modes(ethqos->phy_mode));
 		return -EINVAL;
 	}
 
 	ethqos->pdev = pdev;
 	ethqos->rgmii_base = devm_platform_ioremap_resource_byname(pdev, "rgmii");
 	if (IS_ERR(ethqos->rgmii_base))
-		return PTR_ERR(ethqos->rgmii_base);
+		return dev_err_probe(dev, PTR_ERR(ethqos->rgmii_base),
+				     "Failed to map rgmii resource\n");
 
 	ethqos->mac_base = stmmac_res.addr;
 
@@ -752,7 +756,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 
 	ethqos->link_clk = devm_clk_get(dev, data->link_clk_name ?: "rgmii");
 	if (IS_ERR(ethqos->link_clk))
-		return PTR_ERR(ethqos->link_clk);
+		return dev_err_probe(dev, PTR_ERR(ethqos->link_clk),
+				     "Failed to get link_clk\n");
 
 	ret = ethqos_clks_config(ethqos, true);
 	if (ret)
@@ -764,7 +769,8 @@ static int qcom_ethqos_probe(struct platform_device *pdev)
 
 	ethqos->serdes_phy = devm_phy_optional_get(dev, "serdes");
 	if (IS_ERR(ethqos->serdes_phy))
-		return PTR_ERR(ethqos->serdes_phy);
+		return dev_err_probe(dev, PTR_ERR(ethqos->serdes_phy),
+				     "Failed to get serdes phy\n");
 
 	ethqos->speed = SPEED_1000;
 	ethqos_update_link_clk(ethqos, SPEED_1000);
Signature · 1 line
2.41.0
#6 lore raw
In reply to Andrew Halaney
This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Hello:

This series was applied to netdev/net-next.git (main) by David S. Miller <[email protected]>:

Quoted 9 lines · On Mon, 10 Jul 2023 15:06:36 -0500 you wrote:

This series includes some very minor quality of life patches in the error handling.

I recently ran into a few issues where these patches would have made my life easier (messing with the devicetree, dependent driver of this failing, and incorrect kernel configs resulting in this driver not probing).

[...]

Here is the summary with links:
- [net-next,v2,1/3] net: stmmac: dwmac-qcom-ethqos: Use of_get_phy_mode() over device_get_phy_mode()

    https://git.kernel.org/netdev/net-next/c/a8aa20a64ef2
  - [net-next,v2,2/3] net: stmmac: dwmac-qcom-ethqos: Use dev_err_probe()
    https://git.kernel.org/netdev/net-next/c/b2f3d915b4fe
  - [net-next,v2,3/3] net: stmmac: dwmac-qcom-ethqos: Log more errors in probe
    https://git.kernel.org/netdev/net-next/c/27381e72a2db

You are awesome, thank you!

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