From: Markus Niebel Date: Fri, 21 Nov 2025 17:34:45 +0000 (+0100) Subject: net: fec_mxc: rewrite fallback MDIO Bus allocation X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fc199c481c6a0737d4020ea0cbbab84a2d87b1fd;p=thirdparty%2Fu-boot.git net: fec_mxc: rewrite fallback MDIO Bus allocation The code should only be executed if MDIO bus is not assigned. Otherwise the already assigned / allocated bus will be overwritten. Add condition check and simplify the code to make it more readable. Signed-off-by: Markus Niebel Signed-off-by: Alexander Stein Signed-off-by: Alexander Feilke --- diff --git a/drivers/net/fec_mxc.c b/drivers/net/fec_mxc.c index 69a76e879b1..af6a799e167 100644 --- a/drivers/net/fec_mxc.c +++ b/drivers/net/fec_mxc.c @@ -1373,14 +1373,18 @@ static int fecmxc_probe(struct udevice *dev) if (!bus) bus = fec_get_miibus(dev, (ulong)priv->eth, dev_seq(dev)); #else + if (!bus) { + ulong regs = (ulong)priv->eth; - dm_mii_bus = false; -#ifdef CONFIG_FEC_MXC_MDIO_BASE - bus = fec_get_miibus(dev, (ulong)CONFIG_FEC_MXC_MDIO_BASE, dev_seq(dev)); -#else - bus = fec_get_miibus(dev, (ulong)priv->eth, dev_seq(dev)); + dm_mii_bus = false; + +#if defined(CONFIG_FEC_MXC_MDIO_BASE) + regs = CONFIG_FEC_MXC_MDIO_BASE; #endif + bus = fec_get_miibus(dev, regs, dev_seq(dev)); + } + #endif /* CONFIG_DM_ETH_PHY */ if (!bus) { ret = -ENOMEM;