net: fec: Don't use disabled phys
PATCH v2 1/2 net: fec: Don't use disabled phys
If a phy is disabled, don't use it. This matches Linux's behavior.
---
Changes in v2:
- Fix debug statement missing a parameter.
- Assign phy_of_node only after we determine if the node is available.
drivers/net/fec_mxc.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/net/fec_mxc.c +9 -6
@@ -1299,16 +1299,19 @@ static const struct eth_ops fecmxc_ops = {static int device_get_phy_addr (struct fec_priv *priv,struct udevice *dev) {struct ofnode_phandle_args phandle_args; -int reg; +int reg, ret; -if (dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , - &phandle_args)) { -debug ("Failed to find phy-handle" ); -return -ENODEV ; + ret =dev_read_phandle_with_args (dev,"phy-handle" ,NULL ,0 ,0 , + &phandle_args); +if (ret) { +debug ("Failed to find phy-handle (err = %d\n)" , ret); +return ret; } - priv->phy_of_node = phandle_args.node; +if (!ofnode_is_available (phandle_args.node)) +return -ENOENT ; + priv->phy_of_node = phandle_args.node; reg =ofnode_read_u32_default (phandle_args.node,"reg" ,0 );return reg;
Signature · 1 line
2.25.1
PATCH v2 2/2 net: fec: Only unregister MII bus if we registered it
If we fail to probe for whatever reason, we cannot unregister/free the MII bus unless we registered it with fec_get_miibus. This fixes FECs sharing an MDIO bus from destroying it, preventing the other FEC from using it.
---
(no changes since v1)
drivers/net/fec_mxc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-)
drivers/net/fec_mxc.c +6 -2
@@ -1355,6 +1355,7 @@ static void fec_gpio_reset(struct fec_priv *priv)static int fecmxc_probe (struct udevice *dev) { +bool dm_mii_bus = true;struct eth_pdata *pdata =dev_get_plat (dev);struct fec_priv *priv =dev_get_priv (dev);struct mii_dev *bus =NULL ;
@@ -1462,6 +1463,7 @@ static int fecmxc_probe(struct udevice *dev)#endif if (!bus) { + dm_mii_bus = false;#ifdef CONFIG_FEC_MXC_MDIO_BASE bus =fec_get_miibus ((ulong )CONFIG_FEC_MXC_MDIO_BASE ,dev_seq (dev));
@@ -1507,8 +1509,10 @@ static int fecmxc_probe(struct udevice *dev)return 0 ; err_phy: -mdio_unregister (bus); -free (bus); +if (!dm_mii_bus) { +mdio_unregister (bus); +free (bus); + } err_mii: err_timeout:fec_free_descs (priv);
Signature · 1 line
2.25.1
PATCH v2 2/2 net: fec: Only unregister MII bus if we registered it
Quoted 7 lines
If we fail to probe for whatever reason, we cannot unregister/free the MII bus unless we registered it with
fec_get_miibus. This fixes FECs sharing an MDIO bus from destroying it, preventing the other FEC from using it.Fixes 6a895d039b ("net: Update eQos driver and FEC driver to use eth phy interfaces")Signed-off-by Sean Anderson <[email protected]>Reviewed-by Ramon Fried <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================
PATCH v2 1/2 net: fec: Don't use disabled phys
In reply to Sean AndersonQuoted 3 lines
If a phy is disabled, don't use it. This matches Linux's behavior.
Signed-off-by Sean Anderson <[email protected]>Reviewed-by Ramon Fried <[email protected]>
Applied to u-boot-imx, master, thanks !
Best regards,
Stefano Babic
Signature · 5 lines
===================================================================== DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-53 Fax: +49-8142-66989-80 Email: sbabic at denx.de =====================================================================