Skip to contentSkip to conversation

Messon: Simplify error handling with dev_err_probe()

PATCH Applied Anand Moon 3 participants 14 messages Apr 10, 2025 – Apr 11, 2025

Subsystems (2)
lore
Share & tools
lore

Anand Moon

author
#0 lore raw

cover Messon: Simplify error handling with dev_err_probe()

Hi All,

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

Note: The following patch for RTC:

phy: amlogic: phy-meson-axg-pcie: Fix PHY creation order in axg-pcie probe

has not been tested as I do not have access to the Amlogic AGX hardware. However, I have made improvements to this change based on my understanding of other code.

Thanks
-Anand

Anand Moon (6):
phy: amlogic: phy-meson-gxl-usb2: Simplify error handling with

    dev_err_probe()
  phy: amlogic: phy-meson-g12a-usb2: Simplify error handling with
    dev_err_probe()
  phy: amlogic: phy-meson-axg-mipi-pcie-analog: Simplify error handling
    with dev_err_probe()
  phy: amlogic: phy-meson-axg-mipi-dphy: Simplify error handling with
    dev_err_probe()
  phy: amlogic: phy-meson-axg-pcie: Simplify error handling with
    dev_err_probe()

phy: amlogic: phy-meson-axg-pcie: Fix PHY creation order in axg-pcie
probe

 drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c      | 10 +++-------
 .../phy/amlogic/phy-meson-axg-mipi-pcie-analog.c   | 10 +++-------
 drivers/phy/amlogic/phy-meson-axg-pcie.c           | 14 +++++---------
 drivers/phy/amlogic/phy-meson-g12a-usb2.c          | 10 +++-------
 drivers/phy/amlogic/phy-meson-gxl-usb2.c           | 11 +++--------
 5 files changed, 17 insertions(+), 38 deletions(-)

base-commit: 3b07108ada81a8ebcebf1fe61367b4e436c895bd

Signature · 1 line
2.49.0
author
#1 lore raw

PATCH 1/6 phy: amlogic: phy-meson-gxl-usb2: Simplify error handling with dev_err_probe()

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
 drivers/phy/amlogic/phy-meson-gxl-usb2.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)
drivers/phy/amlogic/phy-meson-gxl-usb2.c +3 -8
index 14ea89927ab14..6b390304f723c 100644
@@ -237,7 +237,6 @@ static int phy_meson_gxl_usb2_probe(struct platform_device *pdev)
 	struct phy_meson_gxl_usb2_priv *priv;
 	struct phy *phy;
 	void __iomem *base;
-	int ret;
 
 	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -266,13 +265,9 @@ static int phy_meson_gxl_usb2_probe(struct platform_device *pdev)
 		return PTR_ERR(priv->reset);
 
 	phy = devm_phy_create(dev, NULL, &phy_meson_gxl_usb2_ops);
-	if (IS_ERR(phy)) {
-		ret = PTR_ERR(phy);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to create PHY\n");
-
-		return ret;
-	}
+	if (IS_ERR(phy))
+		return dev_err_probe(dev, PTR_ERR(phy),
+				     "failed to create PHY\n");
 
 	phy_set_drvdata(phy, priv);
 
Signature · 1 line
2.49.0
author
#3 lore raw

PATCH 2/6 phy: amlogic: phy-meson-g12a-usb2: Simplify error handling with dev_err_probe()

In reply to Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
 drivers/phy/amlogic/phy-meson-g12a-usb2.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/phy/amlogic/phy-meson-g12a-usb2.c +3 -7
index 0e0b5c00b676f..66bf0b7ef8ed3 100644
@@ -339,13 +339,9 @@ static int phy_meson_g12a_usb2_probe(struct platform_device *pdev)
 		return ret;
 
 	phy = devm_phy_create(dev, NULL, &phy_meson_g12a_usb2_ops);
-	if (IS_ERR(phy)) {
-		ret = PTR_ERR(phy);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to create PHY\n");
-
-		return ret;
-	}
+	if (IS_ERR(phy))
+		return dev_err_probe(dev, PTR_ERR(phy),
+				     "failed to create PHY\n");
 
 	phy_set_bus_width(phy, 8);
 	phy_set_drvdata(phy, priv);
Signature · 1 line
2.49.0
author
#5 lore raw

PATCH 3/6 phy: amlogic: phy-meson-axg-mipi-pcie-analog: Simplify error handling with dev_err_probe()

In reply to Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
 drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c +3 -7
index ae898f93f97b2..c0ba2852dbb8e 100644
@@ -200,7 +200,6 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
 	struct phy_axg_mipi_pcie_analog_priv *priv;
 	struct device_node *np = dev->of_node, *parent_np;
 	struct regmap *map;
-	int ret;
 
 	priv = devm_kmalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
@@ -219,12 +218,9 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
 	priv->regmap = map;
 
 	priv->phy = devm_phy_create(dev, np, &phy_axg_mipi_pcie_analog_ops);
-	if (IS_ERR(priv->phy)) {
-		ret = PTR_ERR(priv->phy);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to create PHY\n");
-		return ret;
-	}
+	if (IS_ERR(priv->phy))
+		return dev_err_probe(dev, PTR_ERR(priv->phy),
+				     "failed to create PHY\n");
 
 	phy_set_drvdata(priv->phy, priv);
 	dev_set_drvdata(dev, priv);
Signature · 1 line
2.49.0
author
#7 lore raw

PATCH 4/6 phy: amlogic: phy-meson-axg-mipi-dphy: Simplify error handling with dev_err_probe()

In reply to Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
 drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c +3 -7
index 08a86962d9492..c4a56b9d32897 100644
@@ -377,13 +377,9 @@ static int phy_meson_axg_mipi_dphy_probe(struct platform_device *pdev)
 		return ret;
 
 	phy = devm_phy_create(dev, NULL, &phy_meson_axg_mipi_dphy_ops);
-	if (IS_ERR(phy)) {
-		ret = PTR_ERR(phy);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to create PHY\n");
-
-		return ret;
-	}
+	if (IS_ERR(phy))
+		return dev_err_probe(dev, PTR_ERR(phy),
+				     "failed to create PHY\n");
 
 	phy_set_drvdata(phy, priv);
 
Signature · 1 line
2.49.0
author
#9 lore raw

PATCH 5/6 phy: amlogic: phy-meson-axg-pcie: Simplify error handling with dev_err_probe()

In reply to Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
 drivers/phy/amlogic/phy-meson-axg-pcie.c | 10 +++-------
 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/phy/amlogic/phy-meson-axg-pcie.c +3 -7
index 60be5cdc600b3..54baf7b8930e1 100644
@@ -131,19 +131,15 @@ static int phy_axg_pcie_probe(struct platform_device *pdev)
 	struct phy_axg_pcie_priv *priv;
 	struct device_node *np = dev->of_node;
 	void __iomem *base;
-	int ret;
 
 	priv = devm_kmalloc(dev, sizeof(*priv), GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
 	priv->phy = devm_phy_create(dev, np, &phy_axg_pcie_ops);
-	if (IS_ERR(priv->phy)) {
-		ret = PTR_ERR(priv->phy);
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to create PHY\n");
-		return ret;
-	}
+	if (IS_ERR(priv->phy))
+		return dev_err_probe(dev, PTR_ERR(priv->phy),
+				     "failed to create PHY\n");
 
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
Signature · 1 line
2.49.0
author
#11 lore raw

PATCH 6/6 phy: amlogic: phy-meson-axg-pcie: Fix PHY creation order in axg-pcie probe

In reply to Anand Moon

Reorder the PHY creation in the axg-pcie probe function to ensure all the resource is mapped before creating the PHY. This change addresses the issue where the PHY creation was attempted before mapping the necessary resources, potentially causing failures.

---
 drivers/phy/amlogic/phy-meson-axg-pcie.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/phy/amlogic/phy-meson-axg-pcie.c +5 -5
index 54baf7b8930e1..14dee73f9cb57 100644
@@ -136,11 +136,6 @@ static int phy_axg_pcie_probe(struct platform_device *pdev)
 	if (!priv)
 		return -ENOMEM;
 
-	priv->phy = devm_phy_create(dev, np, &phy_axg_pcie_ops);
-	if (IS_ERR(priv->phy))
-		return dev_err_probe(dev, PTR_ERR(priv->phy),
-				     "failed to create PHY\n");
-
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
 		return PTR_ERR(base);
@@ -158,6 +153,11 @@ static int phy_axg_pcie_probe(struct platform_device *pdev)
 	if (IS_ERR(priv->analog))
 		return PTR_ERR(priv->analog);
 
+	priv->phy = devm_phy_create(dev, np, &phy_axg_pcie_ops);
+	if (IS_ERR(priv->phy))
+		return dev_err_probe(dev, PTR_ERR(priv->phy),
+				     "failed to create PHY\n");
+
 	phy_set_drvdata(priv->phy, priv);
 	dev_set_drvdata(dev, priv);
 	pphy = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
Signature · 1 line
2.49.0
maintainer Reviewed-by on v1 1/6
#2 lore raw

Re: [PATCH v1 1/6] phy: amlogic: phy-meson-gxl-usb2: Simplify error handling with dev_err_probe()

In reply to Anand Moon
Quoted 27 lines · Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
  drivers/phy/amlogic/phy-meson-gxl-usb2.c | 11 +++--------
  1 file changed, 3 insertions(+), 8 deletions(-)
drivers/phy/amlogic/phy-meson-gxl-usb2.c +0 -4
index 14ea89927ab14..6b390304f723c 100644
@@ -237,7 +237,6 @@ static int phy_meson_gxl_usb2_probe(struct platform_device *pdev)
  	struct phy_meson_gxl_usb2_priv *priv;
  	struct phy *phy;
  	void __iomem *base;
-	int ret;
 
  	priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
  	if (!priv)
@@ -266,13 +265,9 @@ static int phy_meson_gxl_usb2_probe(struct platform_device *pdev)
  		return PTR_ERR(priv->reset);
 
  	phy = devm_phy_create(dev, NULL, &phy_meson_gxl_usb2_ops);
-	if (IS_ERR(phy)) {
-		ret = PTR_ERR(phy);
-		if (ret != -EPROBE_DEFER)

drivers/phy/amlogic/phy-meson-gxl-usb2.c static int phy_meson_gxl_usb2_probe(struct platform_device *pdev) · line 273

Quoted 10 lines
drivers/phy/amlogic/phy-meson-gxl-usb2.c +3 -4
-			dev_err(dev, "failed to create PHY\n");
-
-		return ret;
-	}
+	if (IS_ERR(phy))
+		return dev_err_probe(dev, PTR_ERR(phy),
+				     "failed to create PHY\n");
 
  	phy_set_drvdata(phy, priv);
 
maintainer Reviewed-by on v1 2/6
#4 lore raw

Re: [PATCH v1 2/6] phy: amlogic: phy-meson-g12a-usb2: Simplify error handling with dev_err_probe()

In reply to Anand Moon
Quoted 19 lines · Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
  drivers/phy/amlogic/phy-meson-g12a-usb2.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)
drivers/phy/amlogic/phy-meson-g12a-usb2.c +0 -3
index 0e0b5c00b676f..66bf0b7ef8ed3 100644
@@ -339,13 +339,9 @@ static int phy_meson_g12a_usb2_probe(struct platform_device *pdev)
  		return ret;
 
  	phy = devm_phy_create(dev, NULL, &phy_meson_g12a_usb2_ops);
-	if (IS_ERR(phy)) {
-		ret = PTR_ERR(phy);
-		if (ret != -EPROBE_DEFER)

drivers/phy/amlogic/phy-meson-g12a-usb2.c static int phy_meson_g12a_usb2_probe(struct platform_device *pdev) · line 347

Quoted 10 lines
drivers/phy/amlogic/phy-meson-g12a-usb2.c +3 -4
-			dev_err(dev, "failed to create PHY\n");
-
-		return ret;
-	}
+	if (IS_ERR(phy))
+		return dev_err_probe(dev, PTR_ERR(phy),
+				     "failed to create PHY\n");
 
  	phy_set_bus_width(phy, 8);
  	phy_set_drvdata(phy, priv);
maintainer Reviewed-by on v1 3/6
#6 lore raw

Re: [PATCH v1 3/6] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Simplify error handling with dev_err_probe()

In reply to Anand Moon
Quoted 26 lines · Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
  drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)
drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c +0 -3
index ae898f93f97b2..c0ba2852dbb8e 100644
@@ -200,7 +200,6 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
  	struct phy_axg_mipi_pcie_analog_priv *priv;
  	struct device_node *np = dev->of_node, *parent_np;
  	struct regmap *map;
-	int ret;
 
  	priv = devm_kmalloc(dev, sizeof(*priv), GFP_KERNEL);
  	if (!priv)
@@ -219,12 +218,9 @@ static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev)
  	priv->regmap = map;
 
  	priv->phy = devm_phy_create(dev, np, &phy_axg_mipi_pcie_analog_ops);
-	if (IS_ERR(priv->phy)) {
-		ret = PTR_ERR(priv->phy);

drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c static int phy_axg_mipi_pcie_analog_probe(struct platform_device *pdev) · line 226

Quoted 10 lines
drivers/phy/amlogic/phy-meson-axg-mipi-pcie-analog.c +3 -4
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to create PHY\n");
-		return ret;
-	}
+	if (IS_ERR(priv->phy))
+		return dev_err_probe(dev, PTR_ERR(priv->phy),
+				     "failed to create PHY\n");
 
  	phy_set_drvdata(priv->phy, priv);
  	dev_set_drvdata(dev, priv);
maintainer Reviewed-by on v1 4/6
#8 lore raw

Re: [PATCH v1 4/6] phy: amlogic: phy-meson-axg-mipi-dphy: Simplify error handling with dev_err_probe()

In reply to Anand Moon
Quoted 19 lines · Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
  drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)
drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c +0 -3
index 08a86962d9492..c4a56b9d32897 100644
@@ -377,13 +377,9 @@ static int phy_meson_axg_mipi_dphy_probe(struct platform_device *pdev)
  		return ret;
 
  	phy = devm_phy_create(dev, NULL, &phy_meson_axg_mipi_dphy_ops);
-	if (IS_ERR(phy)) {
-		ret = PTR_ERR(phy);
-		if (ret != -EPROBE_DEFER)

drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c static int phy_meson_axg_mipi_dphy_probe(struct platform_device *pdev) · line 385

Quoted 10 lines
drivers/phy/amlogic/phy-meson-axg-mipi-dphy.c +3 -4
-			dev_err(dev, "failed to create PHY\n");
-
-		return ret;
-	}
+	if (IS_ERR(phy))
+		return dev_err_probe(dev, PTR_ERR(phy),
+				     "failed to create PHY\n");
 
  	phy_set_drvdata(phy, priv);
 
maintainer Reviewed-by on v1 5/6
#10 lore raw

Re: [PATCH v1 5/6] phy: amlogic: phy-meson-axg-pcie: Simplify error handling with dev_err_probe()

In reply to Anand Moon
Quoted 25 lines · Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

---
  drivers/phy/amlogic/phy-meson-axg-pcie.c | 10 +++-------
  1 file changed, 3 insertions(+), 7 deletions(-)
drivers/phy/amlogic/phy-meson-axg-pcie.c +0 -3
index 60be5cdc600b3..54baf7b8930e1 100644
@@ -131,19 +131,15 @@ static int phy_axg_pcie_probe(struct platform_device *pdev)
  	struct phy_axg_pcie_priv *priv;
  	struct device_node *np = dev->of_node;
  	void __iomem *base;
-	int ret;
 
  	priv = devm_kmalloc(dev, sizeof(*priv), GFP_KERNEL);
  	if (!priv)
  		return -ENOMEM;
 
  	priv->phy = devm_phy_create(dev, np, &phy_axg_pcie_ops);
-	if (IS_ERR(priv->phy)) {
-		ret = PTR_ERR(priv->phy);

drivers/phy/amlogic/phy-meson-axg-pcie.c static int phy_axg_pcie_probe(struct platform_device *pdev) · line 145

Quoted 10 lines
drivers/phy/amlogic/phy-meson-axg-pcie.c +3 -4
-		if (ret != -EPROBE_DEFER)
-			dev_err(dev, "failed to create PHY\n");
-		return ret;
-	}
+	if (IS_ERR(priv->phy))
+		return dev_err_probe(dev, PTR_ERR(priv->phy),
+				     "failed to create PHY\n");
 
  	base = devm_platform_ioremap_resource(pdev, 0);
  	if (IS_ERR(base))
maintainer Reviewed-by on v1 6/6
#12 lore raw

Re: [PATCH v1 6/6] phy: amlogic: phy-meson-axg-pcie: Fix PHY creation order in axg-pcie probe

In reply to Anand Moon
Quoted 28 lines · Anand Moon

Reorder the PHY creation in the axg-pcie probe function to ensure all the resource is mapped before creating the PHY. This change addresses the issue where the PHY creation was attempted before mapping the necessary resources, potentially causing failures.

---
  drivers/phy/amlogic/phy-meson-axg-pcie.c | 10 +++++-----
  1 file changed, 5 insertions(+), 5 deletions(-)
drivers/phy/amlogic/phy-meson-axg-pcie.c +0 -5
index 54baf7b8930e1..14dee73f9cb57 100644
@@ -136,11 +136,6 @@ static int phy_axg_pcie_probe(struct platform_device *pdev)
  	if (!priv)
  		return -ENOMEM;
 
-	priv->phy = devm_phy_create(dev, np, &phy_axg_pcie_ops);
-	if (IS_ERR(priv->phy))
-		return dev_err_probe(dev, PTR_ERR(priv->phy),
-				     "failed to create PHY\n");
-
  	base = devm_platform_ioremap_resource(pdev, 0);
  	if (IS_ERR(base))
  		return PTR_ERR(base);
@@ -158,6 +153,11 @@ static int phy_axg_pcie_probe(struct platform_device *pdev)
  	if (IS_ERR(priv->analog))

drivers/phy/amlogic/phy-meson-axg-pcie.c static int phy_axg_pcie_probe(struct platform_device *pdev) · line 163

Quoted 10 lines
drivers/phy/amlogic/phy-meson-axg-pcie.c +5 -0
  		return PTR_ERR(priv->analog);
 
+	priv->phy = devm_phy_create(dev, np, &phy_axg_pcie_ops);
+	if (IS_ERR(priv->phy))
+		return dev_err_probe(dev, PTR_ERR(priv->phy),
+				     "failed to create PHY\n");
+
  	phy_set_drvdata(priv->phy, priv);
  	dev_set_drvdata(dev, priv);
  	pphy = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
maintainer Applied
#13 lore raw
In reply to Anand Moon
Quoted 8 lines · Anand Moon

Use dev_err_probe() for phy resources to indicate the deferral reason when waiting for the resource to come up.

Note: The following patch for RTC:

phy: amlogic: phy-meson-axg-pcie: Fix PHY creation order in axg-pcie probe

[...]

Applied, thanks!

[1/6] phy: amlogic: phy-meson-gxl-usb2: Simplify error handling with dev_err_probe()

      commit: 05457917e50c3d6bf75d2e3b99c7e6709a4a6844
[2/6] phy: amlogic: phy-meson-g12a-usb2: Simplify error handling with dev_err_probe()
      commit: 9bff4ef29a6409850c27df705da54277a8e836f2
[3/6] phy: amlogic: phy-meson-axg-mipi-pcie-analog: Simplify error handling with dev_err_probe()
      commit: de39730f9258e9984892c0af68a3e884ad19acea
[4/6] phy: amlogic: phy-meson-axg-mipi-dphy: Simplify error handling with dev_err_probe()
      commit: a77e2e899841937798bff0924c03d4d0e4963aa3
[5/6] phy: amlogic: phy-meson-axg-pcie: Simplify error handling with dev_err_probe()
      commit: fef364bd4c9cf712c91e0013f5f304f4e7f09198
[6/6] phy: amlogic: phy-meson-axg-pcie: Fix PHY creation order in axg-pcie probe
      commit: bdeff6d8a211c832f5ce1a65aff17f4a5e6de00f

Best regards,

Signature · 1 line
~Vinod