diff mbox series

[5/6] drivers: net: fsl_enetc: require a PHY device when probing

Message ID 20210617143554.2104712-6-vladimir.oltean@nxp.com
State Superseded
Delegated to: Priyanka Jain
Headers show
Series Fixes for the NXP LS1028A-QDS boards | expand

Commit Message

Vladimir Oltean June 17, 2021, 2:35 p.m. UTC
Given that even a fixed-link has an associated phy_device, there is no
reason to operate in a mode when dm_eth_phy_connect fails.

Remove the driver checks for a NULL priv->phy and just return -ENODEV
when that happens.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
 drivers/net/fsl_enetc.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

Comments

Ramon Fried June 17, 2021, 6:06 p.m. UTC | #1
On Thu, Jun 17, 2021 at 5:36 PM Vladimir Oltean <vladimir.oltean@nxp.com> wrote:
>
> Given that even a fixed-link has an associated phy_device, there is no
> reason to operate in a mode when dm_eth_phy_connect fails.
>
> Remove the driver checks for a NULL priv->phy and just return -ENODEV
> when that happens.
>
> Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
> ---
>  drivers/net/fsl_enetc.c | 13 +++++--------
>  1 file changed, 5 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
> index f6fc7801b95b..5961775024ff 100644
> --- a/drivers/net/fsl_enetc.c
> +++ b/drivers/net/fsl_enetc.c
> @@ -281,21 +281,20 @@ static void enetc_start_pcs(struct udevice *dev)
>  }
>
>  /* Configure the actual/external ethernet PHY, if one is found */
> -static void enetc_config_phy(struct udevice *dev)
> +static int enetc_config_phy(struct udevice *dev)
>  {
>         struct enetc_priv *priv = dev_get_priv(dev);
>         int supported;
>
>         priv->phy = dm_eth_phy_connect(dev);
> -
>         if (!priv->phy)
> -               return;
> +               return -ENODEV;
>
>         supported = PHY_GBIT_FEATURES | SUPPORTED_2500baseX_Full;
>         priv->phy->supported &= supported;
>         priv->phy->advertising &= supported;
>
> -       phy_config(priv->phy);
> +       return phy_config(priv->phy);
>  }
>
>  /*
> @@ -335,9 +334,8 @@ static int enetc_probe(struct udevice *dev)
>         dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY);
>
>         enetc_start_pcs(dev);
> -       enetc_config_phy(dev);
>
> -       return 0;
> +       return enetc_config_phy(dev);
>  }
>
>  /*
> @@ -550,8 +548,7 @@ static int enetc_start(struct udevice *dev)
>
>         enetc_setup_mac_iface(dev);
>
> -       if (priv->phy)
> -               phy_startup(priv->phy);
> +       phy_startup(priv->phy);
>
>         return 0;
>  }
> --
> 2.25.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
diff mbox series

Patch

diff --git a/drivers/net/fsl_enetc.c b/drivers/net/fsl_enetc.c
index f6fc7801b95b..5961775024ff 100644
--- a/drivers/net/fsl_enetc.c
+++ b/drivers/net/fsl_enetc.c
@@ -281,21 +281,20 @@  static void enetc_start_pcs(struct udevice *dev)
 }
 
 /* Configure the actual/external ethernet PHY, if one is found */
-static void enetc_config_phy(struct udevice *dev)
+static int enetc_config_phy(struct udevice *dev)
 {
 	struct enetc_priv *priv = dev_get_priv(dev);
 	int supported;
 
 	priv->phy = dm_eth_phy_connect(dev);
-
 	if (!priv->phy)
-		return;
+		return -ENODEV;
 
 	supported = PHY_GBIT_FEATURES | SUPPORTED_2500baseX_Full;
 	priv->phy->supported &= supported;
 	priv->phy->advertising &= supported;
 
-	phy_config(priv->phy);
+	return phy_config(priv->phy);
 }
 
 /*
@@ -335,9 +334,8 @@  static int enetc_probe(struct udevice *dev)
 	dm_pci_clrset_config16(dev, PCI_COMMAND, 0, PCI_COMMAND_MEMORY);
 
 	enetc_start_pcs(dev);
-	enetc_config_phy(dev);
 
-	return 0;
+	return enetc_config_phy(dev);
 }
 
 /*
@@ -550,8 +548,7 @@  static int enetc_start(struct udevice *dev)
 
 	enetc_setup_mac_iface(dev);
 
-	if (priv->phy)
-		phy_startup(priv->phy);
+	phy_startup(priv->phy);
 
 	return 0;
 }