[1/6] net: phy: maxio: prepare for more DT properties

Message ID 20260803101452.2993721-2-andre.przywara@arm.com (mailing list archive)
State New
Headers
Series sunxi: net: add Ethernet support for X96QPro+ |

Commit Message

Andre Przywara Aug. 3, 2026, 10:14 a.m. UTC
The probe routine for the Maxio PHY returns early if the optional
maxio,clk-out-frequency-hz property is not found. That prevents looking
for other properties.

Refactor the routine to handle the property in an if-clause, to allow
more actions in the probe routine later.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
---
 drivers/net/phy/maxio.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)
  

Comments

Andrew Lunn Aug. 4, 2026, 2:42 a.m. UTC | #1
On Mon, Aug 03, 2026 at 12:14:47PM +0200, Andre Przywara wrote:
> The probe routine for the Maxio PHY returns early if the optional
> maxio,clk-out-frequency-hz property is not found. That prevents looking
> for other properties.
> 
> Refactor the routine to handle the property in an if-clause, to allow
> more actions in the probe routine later.
> 
> Signed-off-by: Andre Przywara <andre.przywara@arm.com>
> ---
>  drivers/net/phy/maxio.c | 18 +++++++++---------
>  1 file changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/phy/maxio.c b/drivers/net/phy/maxio.c
> index d2cb23895646..95a2169f25df 100644
> --- a/drivers/net/phy/maxio.c
> +++ b/drivers/net/phy/maxio.c
> @@ -43,18 +43,18 @@ static int maxio_mae0621a_probe(struct phy_device *phydev)
>  
>  	ret = device_property_read_u32(dev, "maxio,clk-out-frequency-hz",
>  				       &frequency);
> -	if (ret == -EINVAL)
> -		return 0;
> -	if (ret)
> +	if (!ret) {
> +		if (frequency != 125000000) {
> +			phydev_err(phydev, "invalid CLKOUT frequency %u\n",
> +				   frequency);
> +			return -EINVAL;
> +		}
> +
> +		priv->clk_out_125m = true;
> +	} else if (ret != -EINVAL) {
>  		return ret;

The normal pattern is to check for errors and return them. So i would
do this test first.

 	ret = device_property_read_u32(dev, "maxio,clk-out-frequency-hz",
  				       &frequency);
        if (ret) {
	   if (ret != -EINVAL)
	        return ret;
	} else {
		if (frequency != 125000000) {
			phydev_err(phydev, "invalid CLKOUT frequency %u\n",
				   frequency);
			return -EINVAL;
		}

		priv->clk_out_125m = true;
        }


	Andrew
  

Patch

diff --git a/drivers/net/phy/maxio.c b/drivers/net/phy/maxio.c
index d2cb23895646..95a2169f25df 100644
--- a/drivers/net/phy/maxio.c
+++ b/drivers/net/phy/maxio.c
@@ -43,18 +43,18 @@  static int maxio_mae0621a_probe(struct phy_device *phydev)
 
 	ret = device_property_read_u32(dev, "maxio,clk-out-frequency-hz",
 				       &frequency);
-	if (ret == -EINVAL)
-		return 0;
-	if (ret)
+	if (!ret) {
+		if (frequency != 125000000) {
+			phydev_err(phydev, "invalid CLKOUT frequency %u\n",
+				   frequency);
+			return -EINVAL;
+		}
+
+		priv->clk_out_125m = true;
+	} else if (ret != -EINVAL) {
 		return ret;
-
-	if (frequency != 125000000) {
-		phydev_err(phydev, "invalid CLKOUT frequency %u\n", frequency);
-		return -EINVAL;
 	}
 
-	priv->clk_out_125m = true;
-
 	return 0;
 }