All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] net: phy: corrected the return value for genphy_check_and_restart_aneg
@ 2020-02-25 12:22 Sudheesh Mavila
  2020-02-25 12:38 ` Russell King - ARM Linux admin
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sudheesh Mavila @ 2020-02-25 12:22 UTC (permalink / raw)
  To: sudheesh.mavila, andrew, f.fainelli, hkallweit1, linux, davem,
	netdev, linux-kernel

When auto-negotiation is not required, return value should be zero.

Signed-off-by: Sudheesh Mavila <sudheesh.mavila@amd.com>
---
 drivers/net/phy/phy_device.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 6a5056e0ae77..36cde3dac4c3 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -1806,10 +1806,13 @@ int genphy_check_and_restart_aneg(struct phy_device *phydev, bool restart)
 			restart = true;
 	}
 
-	if (restart)
-		ret = genphy_restart_aneg(phydev);
+	/* Only restart aneg if we are advertising something different
+	 * than we were before.
+	 */
+	if (restart > 0)
+		return genphy_restart_aneg(phydev);
 
-	return ret;
+	return 0;
 }
 EXPORT_SYMBOL(genphy_check_and_restart_aneg);
 
-- 
2.17.1


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

* Re: [PATCH] net: phy: corrected the return value for genphy_check_and_restart_aneg
  2020-02-25 12:22 [PATCH] net: phy: corrected the return value for genphy_check_and_restart_aneg Sudheesh Mavila
@ 2020-02-25 12:38 ` Russell King - ARM Linux admin
  2020-02-25 13:28 ` Andrew Lunn
  2020-02-25 13:59 ` Heiner Kallweit
  2 siblings, 0 replies; 4+ messages in thread
From: Russell King - ARM Linux admin @ 2020-02-25 12:38 UTC (permalink / raw)
  To: Sudheesh Mavila
  Cc: andrew, f.fainelli, hkallweit1, davem, netdev, linux-kernel

On Tue, Feb 25, 2020 at 05:52:08PM +0530, Sudheesh Mavila wrote:
> When auto-negotiation is not required, return value should be zero.
> 
> Signed-off-by: Sudheesh Mavila <sudheesh.mavila@amd.com>

Hi,

Thanks for spotting this problem. However, it looks like the same
problem also exists in genphy_c45_check_and_restart_aneg(). It would
be a good idea to fix both at the same time.

Thanks.

> ---
>  drivers/net/phy/phy_device.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 6a5056e0ae77..36cde3dac4c3 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1806,10 +1806,13 @@ int genphy_check_and_restart_aneg(struct phy_device *phydev, bool restart)
>  			restart = true;
>  	}
>  
> -	if (restart)
> -		ret = genphy_restart_aneg(phydev);
> +	/* Only restart aneg if we are advertising something different
> +	 * than we were before.
> +	 */
> +	if (restart > 0)
> +		return genphy_restart_aneg(phydev);
>  
> -	return ret;
> +	return 0;
>  }
>  EXPORT_SYMBOL(genphy_check_and_restart_aneg);
>  
> -- 
> 2.17.1
> 
> 

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

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

* Re: [PATCH] net: phy: corrected the return value for genphy_check_and_restart_aneg
  2020-02-25 12:22 [PATCH] net: phy: corrected the return value for genphy_check_and_restart_aneg Sudheesh Mavila
  2020-02-25 12:38 ` Russell King - ARM Linux admin
@ 2020-02-25 13:28 ` Andrew Lunn
  2020-02-25 13:59 ` Heiner Kallweit
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Lunn @ 2020-02-25 13:28 UTC (permalink / raw)
  To: Sudheesh Mavila
  Cc: f.fainelli, hkallweit1, linux, davem, netdev, linux-kernel

On Tue, Feb 25, 2020 at 05:52:08PM +0530, Sudheesh Mavila wrote:
> When auto-negotiation is not required, return value should be zero.
> 
> Signed-off-by: Sudheesh Mavila <sudheesh.mavila@amd.com>

Fixes: 2a10ab043ac5 ("net: phy: add genphy_check_and_restart_aneg()")

       Andrew

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

* Re: [PATCH] net: phy: corrected the return value for genphy_check_and_restart_aneg
  2020-02-25 12:22 [PATCH] net: phy: corrected the return value for genphy_check_and_restart_aneg Sudheesh Mavila
  2020-02-25 12:38 ` Russell King - ARM Linux admin
  2020-02-25 13:28 ` Andrew Lunn
@ 2020-02-25 13:59 ` Heiner Kallweit
  2 siblings, 0 replies; 4+ messages in thread
From: Heiner Kallweit @ 2020-02-25 13:59 UTC (permalink / raw)
  To: Sudheesh Mavila, andrew, f.fainelli, linux, davem, netdev, linux-kernel

On 25.02.2020 13:22, Sudheesh Mavila wrote:
> When auto-negotiation is not required, return value should be zero.
> 
> Signed-off-by: Sudheesh Mavila <sudheesh.mavila@amd.com>
> ---
>  drivers/net/phy/phy_device.c | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
> index 6a5056e0ae77..36cde3dac4c3 100644
> --- a/drivers/net/phy/phy_device.c
> +++ b/drivers/net/phy/phy_device.c
> @@ -1806,10 +1806,13 @@ int genphy_check_and_restart_aneg(struct phy_device *phydev, bool restart)
>  			restart = true;
>  	}
>  
> -	if (restart)
> -		ret = genphy_restart_aneg(phydev);
> +	/* Only restart aneg if we are advertising something different
> +	 * than we were before.
> +	 */
> +	if (restart > 0)

In addition to what Russell and Andrew commented already:
- You shouldn't compare a bool with an int. There's no need to change
  the original condition.
- The comment isn't really needed, and it's wrong. See the comment few
  lines earlier.
- After this change the initialization of ret isn't needed any longer.

> +		return genphy_restart_aneg(phydev);
>  
> -	return ret;
> +	return 0;
>  }
>  EXPORT_SYMBOL(genphy_check_and_restart_aneg);
>  
> 


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

end of thread, other threads:[~2020-02-25 13:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-25 12:22 [PATCH] net: phy: corrected the return value for genphy_check_and_restart_aneg Sudheesh Mavila
2020-02-25 12:38 ` Russell King - ARM Linux admin
2020-02-25 13:28 ` Andrew Lunn
2020-02-25 13:59 ` Heiner Kallweit

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.