netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH (net.git)] phy: fix EEE checks inside the phy_init_eee.
@ 2014-08-26  7:26 Giuseppe Cavallaro
  2014-08-26 16:55 ` Florian Fainelli
  2014-08-27 23:30 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Giuseppe Cavallaro @ 2014-08-26  7:26 UTC (permalink / raw)
  To: netdev; +Cc: Giuseppe Cavallaro, Nandini Sharma

According to the Std 802.3az if the EEE Adv (Reg 7.60), Link partner ability
(Reg 7.61) and EEE capability (Register 3.20) bits return 0 this  means no EEE
is supported. So this patch fixes the checks inside the phy_init_eee function.

Signed-off-by: Nandini Sharma <nandini.sharma@st.com>
Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>
---
 drivers/net/phy/phy.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index c94e2a2..a854d38 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -1036,31 +1036,31 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
 		/* First check if the EEE ability is supported */
 		eee_cap = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE,
 						MDIO_MMD_PCS, phydev->addr);
-		if (eee_cap < 0)
-			return eee_cap;
+		if (eee_cap <= 0)
+			goto eee_exit_err;
 
 		cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);
 		if (!cap)
-			return -EPROTONOSUPPORT;
+			goto eee_exit_err;
 
 		/* Check which link settings negotiated and verify it in
 		 * the EEE advertising registers.
 		 */
 		eee_lp = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE,
 					       MDIO_MMD_AN, phydev->addr);
-		if (eee_lp < 0)
-			return eee_lp;
+		if (eee_lp <= 0)
+			goto eee_exit_err;
 
 		eee_adv = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV,
 						MDIO_MMD_AN, phydev->addr);
-		if (eee_adv < 0)
-			return eee_adv;
+		if (eee_adv <= 0)
+			goto eee_exit_err;
 
 		adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);
 		lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);
 		idx = phy_find_setting(phydev->speed, phydev->duplex);
 		if (!(lp & adv & settings[idx].setting))
-			return -EPROTONOSUPPORT;
+			goto eee_exit_err;
 
 		if (clk_stop_enable) {
 			/* Configure the PHY to stop receiving xMII
@@ -1080,7 +1080,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
 
 		return 0; /* EEE supported */
 	}
-
+eee_exit_err:
 	return -EPROTONOSUPPORT;
 }
 EXPORT_SYMBOL(phy_init_eee);
-- 
1.7.4.4

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

* Re: [PATCH (net.git)] phy: fix EEE checks inside the phy_init_eee.
  2014-08-26  7:26 [PATCH (net.git)] phy: fix EEE checks inside the phy_init_eee Giuseppe Cavallaro
@ 2014-08-26 16:55 ` Florian Fainelli
  2014-08-27 23:30 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Florian Fainelli @ 2014-08-26 16:55 UTC (permalink / raw)
  To: Giuseppe Cavallaro, netdev; +Cc: Nandini Sharma

On 08/26/2014 12:26 AM, Giuseppe Cavallaro wrote:
> According to the Std 802.3az if the EEE Adv (Reg 7.60), Link partner ability
> (Reg 7.61) and EEE capability (Register 3.20) bits return 0 this  means no EEE
> is supported. So this patch fixes the checks inside the phy_init_eee function.
> 
> Signed-off-by: Nandini Sharma <nandini.sharma@st.com>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>

> ---
>  drivers/net/phy/phy.c |   18 +++++++++---------
>  1 files changed, 9 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
> index c94e2a2..a854d38 100644
> --- a/drivers/net/phy/phy.c
> +++ b/drivers/net/phy/phy.c
> @@ -1036,31 +1036,31 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
>  		/* First check if the EEE ability is supported */
>  		eee_cap = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE,
>  						MDIO_MMD_PCS, phydev->addr);
> -		if (eee_cap < 0)
> -			return eee_cap;
> +		if (eee_cap <= 0)
> +			goto eee_exit_err;
>  
>  		cap = mmd_eee_cap_to_ethtool_sup_t(eee_cap);
>  		if (!cap)
> -			return -EPROTONOSUPPORT;
> +			goto eee_exit_err;

!cap is most likely not possible anymore now that you are checking that
eee_cap <= 0

>  
>  		/* Check which link settings negotiated and verify it in
>  		 * the EEE advertising registers.
>  		 */
>  		eee_lp = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_LPABLE,
>  					       MDIO_MMD_AN, phydev->addr);
> -		if (eee_lp < 0)
> -			return eee_lp;
> +		if (eee_lp <= 0)
> +			goto eee_exit_err;
>  
>  		eee_adv = phy_read_mmd_indirect(phydev, MDIO_AN_EEE_ADV,
>  						MDIO_MMD_AN, phydev->addr);
> -		if (eee_adv < 0)
> -			return eee_adv;
> +		if (eee_adv <= 0)
> +			goto eee_exit_err;
>  
>  		adv = mmd_eee_adv_to_ethtool_adv_t(eee_adv);
>  		lp = mmd_eee_adv_to_ethtool_adv_t(eee_lp);
>  		idx = phy_find_setting(phydev->speed, phydev->duplex);
>  		if (!(lp & adv & settings[idx].setting))
> -			return -EPROTONOSUPPORT;
> +			goto eee_exit_err;
>  
>  		if (clk_stop_enable) {
>  			/* Configure the PHY to stop receiving xMII
> @@ -1080,7 +1080,7 @@ int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
>  
>  		return 0; /* EEE supported */
>  	}
> -
> +eee_exit_err:
>  	return -EPROTONOSUPPORT;
>  }
>  EXPORT_SYMBOL(phy_init_eee);
> 

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

* Re: [PATCH (net.git)] phy: fix EEE checks inside the phy_init_eee.
  2014-08-26  7:26 [PATCH (net.git)] phy: fix EEE checks inside the phy_init_eee Giuseppe Cavallaro
  2014-08-26 16:55 ` Florian Fainelli
@ 2014-08-27 23:30 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2014-08-27 23:30 UTC (permalink / raw)
  To: peppe.cavallaro; +Cc: netdev, nandini.sharma

From: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Date: Tue, 26 Aug 2014 09:26:52 +0200

> According to the Std 802.3az if the EEE Adv (Reg 7.60), Link partner ability
> (Reg 7.61) and EEE capability (Register 3.20) bits return 0 this  means no EEE
> is supported. So this patch fixes the checks inside the phy_init_eee function.
> 
> Signed-off-by: Nandini Sharma <nandini.sharma@st.com>
> Signed-off-by: Giuseppe Cavallaro <peppe.cavallaro@st.com>

Applied, thanks.

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

end of thread, other threads:[~2014-08-27 23:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-26  7:26 [PATCH (net.git)] phy: fix EEE checks inside the phy_init_eee Giuseppe Cavallaro
2014-08-26 16:55 ` Florian Fainelli
2014-08-27 23:30 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).