All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: designware: Release the clocks if the PHY supply fails
@ 2026-11-03 19:05 Yuho Choi
  2026-11-06 18:06 ` Jerome Forissier
  0 siblings, 1 reply; 2+ messages in thread
From: Yuho Choi @ 2026-11-03 19:05 UTC (permalink / raw)
  To: Jerome Forissier
  Cc: Tom Rini, Patrice Chotard, Michael Chang, Stanley Chu,
	Sean Anderson, Simon Glass, u-boot, Yuho Choi

designware_eth_probe() enables the clocks of the MAC before it enables
the PHY supply. If regulator_set_enable_if_allowed() fails, or on
NPCM8xx if setting "phy-supply-microvolt" fails, the probe returns
directly and skips the clk_release_all() at the end of the function. A
failed probe does not call designware_eth_remove(), so the clocks are
left enabled.

Go to the error path instead, as the later failures in the probe do.
This uses the mdio_err label, because clk_err only exists with
CONFIG_CLK; nothing between the two labels has been set up yet. The
PHY supply itself is still left enabled, as on the other error paths
and in designware_eth_remove().

Fixes: ba1f96672522 ("net: designware: add clock support")
Fixes: 8897f91a5397 ("net: designware: support phy io micro voltage setting.")
Signed-off-by: Yuho Choi <oss.patchbox@gmail.com>
---
Build-tested only, on nanopi-r2s-rk3328 and A20-OLinuXino-Lime2
(CLK=y, DM_REGULATOR=y), arbel_evb (NPCM8XX) and socfpga_arria10
(DM_REGULATOR=n), with no new warnings in designware.c at W=1. I also
compiled designware.c with CONFIG_CLK undefined, since CLK is selected
on all these boards. Not tested at runtime: I have no board where the
PHY supply fails.

 drivers/net/designware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 9470804ebd1..52dd08da82a 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -927,7 +927,8 @@ int designware_eth_probe(struct udevice *dev)
 		ret = regulator_set_enable_if_allowed(phy_supply, true);
 		if (ret) {
 			puts("Error enabling phy supply\n");
-			return ret;
+			err = ret;
+			goto mdio_err;
 		}
 #if IS_ENABLED(CONFIG_ARCH_NPCM8XX)
 		int phy_uv;
@@ -937,7 +938,8 @@ int designware_eth_probe(struct udevice *dev)
 			ret = regulator_set_value(phy_supply, phy_uv);
 			if (ret) {
 				puts("Error setting phy voltage\n");
-				return ret;
+				err = ret;
+				goto mdio_err;
 			}
 		}
 #endif
-- 
2.43.0


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

end of thread, other threads:[~2026-11-06 18:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-03 19:05 [PATCH] net: designware: Release the clocks if the PHY supply fails Yuho Choi
2026-11-06 18:06 ` Jerome Forissier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.