mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2 0/3] phy: renesas: rcar-gen2: three cleanups
@ 2026-08-04 15:24 Felix Gu
  2026-08-04 15:24 ` [PATCH v2 1/3] phy: renesas: rcar-gen2: Fix double of_node_put on phy creation failure Felix Gu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Felix Gu @ 2026-08-04 15:24 UTC (permalink / raw)
  To: Vinod Koul, Neil Armstrong, Geert Uytterhoeven, Magnus Damm,
	Krzysztof Kozlowski, Kishon Vijay Abraham I, Sergei Shtylyov
  Cc: linux-phy, linux-renesas-soc, linux-kernel, Felix Gu

Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
Changes in v2:
- Merge patch 1 and patch 2 into one series.
- Collect Krzysztof's reviewed-by for patch 1.
- Add patch 3 to use dev_err_probe() in probe function.
- Link to v1: https://patch.msgid.link/20260803-rcar-gen2-v1-1-9aa35c36d7d7@gmail.com

To: Vinod Koul <vkoul@kernel.org>
To: Neil Armstrong <neil.armstrong@linaro.org>
To: Geert Uytterhoeven <geert+renesas@glider.be>
To: Magnus Damm <magnus.damm@gmail.com>
To: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
To: Kishon Vijay Abraham I <kishon@kernel.org>
To: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Cc: linux-phy@lists.infradead.org
Cc: linux-renesas-soc@vger.kernel.org
Cc: linux-kernel@vger.kernel.org

---
Felix Gu (3):
      phy: renesas: rcar-gen2: Fix double of_node_put on phy creation failure
      phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg
      phy: renesas: rcar-gen2: Use dev_err_probe() in probe

 drivers/phy/renesas/phy-rcar-gen2.c | 36 ++++++++++++++----------------------
 1 file changed, 14 insertions(+), 22 deletions(-)
---
base-commit: 415606a7be939835db9b0d6b711887586646346d
change-id: 20260803-rcar-gen2-140f014cd384

Best regards,
--  
Felix Gu <ustc.gu@gmail.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/3] phy: renesas: rcar-gen2: Fix double of_node_put on phy creation failure
  2026-08-04 15:24 [PATCH v2 0/3] phy: renesas: rcar-gen2: three cleanups Felix Gu
@ 2026-08-04 15:24 ` Felix Gu
  2026-08-04 15:24 ` [PATCH v2 2/3] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg Felix Gu
  2026-08-04 15:24 ` [PATCH v2 3/3] phy: renesas: rcar-gen2: Use dev_err_probe() in probe Felix Gu
  2 siblings, 0 replies; 4+ messages in thread
From: Felix Gu @ 2026-08-04 15:24 UTC (permalink / raw)
  To: Vinod Koul, Neil Armstrong, Geert Uytterhoeven, Magnus Damm,
	Krzysztof Kozlowski, Kishon Vijay Abraham I, Sergei Shtylyov
  Cc: linux-phy, linux-renesas-soc, linux-kernel, Felix Gu

for_each_child_of_node_scoped() releases the node reference on scope
exit, so the explicit of_node_put(np) in the devm_phy_create() error
path drops it twice.

Drop the redundant of_node_put() and let the scoped cleanup handle it.

Fixes: b64b32791fb5 ("phy: renesas: rcar-gen2: Simplify with scoped for each OF child loop")
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/phy/renesas/phy-rcar-gen2.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
index 6c671254c625..5a272e25e051 100644
--- a/drivers/phy/renesas/phy-rcar-gen2.c
+++ b/drivers/phy/renesas/phy-rcar-gen2.c
@@ -405,7 +405,6 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 						   data->gen2_phy_ops);
 			if (IS_ERR(phy->phy)) {
 				dev_err(dev, "Failed to create PHY\n");
-				of_node_put(np);
 				return PTR_ERR(phy->phy);
 			}
 			phy_set_drvdata(phy->phy, phy);

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 2/3] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg
  2026-08-04 15:24 [PATCH v2 0/3] phy: renesas: rcar-gen2: three cleanups Felix Gu
  2026-08-04 15:24 ` [PATCH v2 1/3] phy: renesas: rcar-gen2: Fix double of_node_put on phy creation failure Felix Gu
@ 2026-08-04 15:24 ` Felix Gu
  2026-08-04 15:24 ` [PATCH v2 3/3] phy: renesas: rcar-gen2: Use dev_err_probe() in probe Felix Gu
  2 siblings, 0 replies; 4+ messages in thread
From: Felix Gu @ 2026-08-04 15:24 UTC (permalink / raw)
  To: Vinod Koul, Neil Armstrong, Geert Uytterhoeven, Magnus Damm,
	Krzysztof Kozlowski, Kishon Vijay Abraham I, Sergei Shtylyov
  Cc: linux-phy, linux-renesas-soc, linux-kernel, Felix Gu

When of_property_read_u32() succeeds but channel_num exceeds
data->num_channels, rcar_gen2_phy_probe() returns error which is 0,
so probe reports success even though no PHY provider is registered.

Return -EINVAL in that case.

Fixes: 1233f59f745b ("phy: Renesas R-Car Gen2 PHY driver")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/phy/renesas/phy-rcar-gen2.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
index 5a272e25e051..b18727ed41a1 100644
--- a/drivers/phy/renesas/phy-rcar-gen2.c
+++ b/drivers/phy/renesas/phy-rcar-gen2.c
@@ -390,7 +390,7 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 		error = of_property_read_u32(np, "reg", &channel_num);
 		if (error || channel_num >= data->num_channels) {
 			dev_err(dev, "Invalid \"reg\" property\n");
-			return error;
+			return error ?: -EINVAL;
 		}
 		channel->select_mask = select_mask[channel_num];
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 3/3] phy: renesas: rcar-gen2: Use dev_err_probe() in probe
  2026-08-04 15:24 [PATCH v2 0/3] phy: renesas: rcar-gen2: three cleanups Felix Gu
  2026-08-04 15:24 ` [PATCH v2 1/3] phy: renesas: rcar-gen2: Fix double of_node_put on phy creation failure Felix Gu
  2026-08-04 15:24 ` [PATCH v2 2/3] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg Felix Gu
@ 2026-08-04 15:24 ` Felix Gu
  2 siblings, 0 replies; 4+ messages in thread
From: Felix Gu @ 2026-08-04 15:24 UTC (permalink / raw)
  To: Vinod Koul, Neil Armstrong, Geert Uytterhoeven, Magnus Damm,
	Krzysztof Kozlowski, Kishon Vijay Abraham I, Sergei Shtylyov
  Cc: linux-phy, linux-renesas-soc, linux-kernel, Felix Gu

Convert the error paths in rcar_gen2_phy_probe() to dev_err_probe().

Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/phy/renesas/phy-rcar-gen2.c | 35 ++++++++++++++---------------------
 1 file changed, 14 insertions(+), 21 deletions(-)

diff --git a/drivers/phy/renesas/phy-rcar-gen2.c b/drivers/phy/renesas/phy-rcar-gen2.c
index b18727ed41a1..581f6768e2bb 100644
--- a/drivers/phy/renesas/phy-rcar-gen2.c
+++ b/drivers/phy/renesas/phy-rcar-gen2.c
@@ -342,17 +342,13 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 	const struct rcar_gen2_phy_data *data;
 	int i = 0;
 
-	if (!dev->of_node) {
-		dev_err(dev,
-			"This driver is required to be instantiated from device tree\n");
-		return -EINVAL;
-	}
+	if (!dev->of_node)
+		return dev_err_probe(dev, -EINVAL,
+				     "This driver is required to be instantiated from device tree\n");
 
 	clk = devm_clk_get(dev, "usbhs");
-	if (IS_ERR(clk)) {
-		dev_err(dev, "Can't get USBHS clock\n");
-		return PTR_ERR(clk);
-	}
+	if (IS_ERR(clk))
+		return dev_err_probe(dev, PTR_ERR(clk), "Can't get USBHS clock\n");
 
 	base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(base))
@@ -388,10 +384,9 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 		channel->selected_phy = -1;
 
 		error = of_property_read_u32(np, "reg", &channel_num);
-		if (error || channel_num >= data->num_channels) {
-			dev_err(dev, "Invalid \"reg\" property\n");
-			return error ?: -EINVAL;
-		}
+		if (error || channel_num >= data->num_channels)
+			return dev_err_probe(dev, error ?: -EINVAL,
+					     "Invalid \"reg\" property\n");
 		channel->select_mask = select_mask[channel_num];
 
 		for (n = 0; n < PHYS_PER_CHANNEL; n++) {
@@ -403,10 +398,9 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 
 			phy->phy = devm_phy_create(dev, NULL,
 						   data->gen2_phy_ops);
-			if (IS_ERR(phy->phy)) {
-				dev_err(dev, "Failed to create PHY\n");
-				return PTR_ERR(phy->phy);
-			}
+			if (IS_ERR(phy->phy))
+				return dev_err_probe(dev, PTR_ERR(phy->phy),
+						     "Failed to create PHY\n");
 			phy_set_drvdata(phy->phy, phy);
 		}
 
@@ -414,10 +408,9 @@ static int rcar_gen2_phy_probe(struct platform_device *pdev)
 	}
 
 	provider = devm_of_phy_provider_register(dev, rcar_gen2_phy_xlate);
-	if (IS_ERR(provider)) {
-		dev_err(dev, "Failed to register PHY provider\n");
-		return PTR_ERR(provider);
-	}
+	if (IS_ERR(provider))
+		return dev_err_probe(dev, PTR_ERR(provider),
+				     "Failed to register PHY provider\n");
 
 	dev_set_drvdata(dev, drv);
 

-- 
2.43.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-04 15:24 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-04 15:24 [PATCH v2 0/3] phy: renesas: rcar-gen2: three cleanups Felix Gu
2026-08-04 15:24 ` [PATCH v2 1/3] phy: renesas: rcar-gen2: Fix double of_node_put on phy creation failure Felix Gu
2026-08-04 15:24 ` [PATCH v2 2/3] phy: renesas: rcar-gen2: Return -EINVAL for out-of-range channel reg Felix Gu
2026-08-04 15:24 ` [PATCH v2 3/3] phy: renesas: rcar-gen2: Use dev_err_probe() in probe Felix Gu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®