Patchwork [net-next,RESEND,2/2] net: phy: at803x: use genphy_config_init()

login
register
mail settings
Submitter Daniel Mack
Date April 16, 2014, 3:19 p.m.
Message ID <1397661553-22117-2-git-send-email-zonque@gmail.com>
Download mbox | patch
Permalink /patch/339623/
State Accepted
Delegated to: David Miller
Headers show

Comments

Daniel Mack - April 16, 2014, 3:19 p.m.
Use the generic bits from genphy_config_init() instead of implementing
the same functionality again.

Signed-off-by: Daniel Mack <zonque@gmail.com>
---
Resending this after 3.15-rc1 has been released, assuming that the
net-next tree is now open again.

 drivers/net/phy/at803x.c | 36 +++---------------------------------
 1 file changed, 3 insertions(+), 33 deletions(-)
Florian Fainelli - April 16, 2014, 7:14 p.m.
2014-04-16 8:19 GMT-07:00 Daniel Mack <zonque@gmail.com>:
> Use the generic bits from genphy_config_init() instead of implementing
> the same functionality again.
>
> Signed-off-by: Daniel Mack <zonque@gmail.com>

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

> ---
> Resending this after 3.15-rc1 has been released, assuming that the
> net-next tree is now open again.
>
>  drivers/net/phy/at803x.c | 36 +++---------------------------------
>  1 file changed, 3 insertions(+), 33 deletions(-)
>
> diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
> index bc71947..850171f 100644
> --- a/drivers/net/phy/at803x.c
> +++ b/drivers/net/phy/at803x.c
> @@ -141,41 +141,11 @@ static int at803x_resume(struct phy_device *phydev)
>
>  static int at803x_config_init(struct phy_device *phydev)
>  {
> -       int val;
>         int ret;
> -       u32 features;
> -
> -       features = SUPPORTED_TP | SUPPORTED_MII | SUPPORTED_AUI |
> -                  SUPPORTED_FIBRE | SUPPORTED_BNC;
> -
> -       val = phy_read(phydev, MII_BMSR);
> -       if (val < 0)
> -               return val;
> -
> -       if (val & BMSR_ANEGCAPABLE)
> -               features |= SUPPORTED_Autoneg;
> -       if (val & BMSR_100FULL)
> -               features |= SUPPORTED_100baseT_Full;
> -       if (val & BMSR_100HALF)
> -               features |= SUPPORTED_100baseT_Half;
> -       if (val & BMSR_10FULL)
> -               features |= SUPPORTED_10baseT_Full;
> -       if (val & BMSR_10HALF)
> -               features |= SUPPORTED_10baseT_Half;
> -
> -       if (val & BMSR_ESTATEN) {
> -               val = phy_read(phydev, MII_ESTATUS);
> -               if (val < 0)
> -                       return val;
> -
> -               if (val & ESTATUS_1000_TFULL)
> -                       features |= SUPPORTED_1000baseT_Full;
> -               if (val & ESTATUS_1000_THALF)
> -                       features |= SUPPORTED_1000baseT_Half;
> -       }
>
> -       phydev->supported = features;
> -       phydev->advertising = features;
> +       ret = genphy_config_init(phydev);
> +       if (ret < 0)
> +               return ret;
>
>         if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
>                 ret = phy_write(phydev, AT803X_DEBUG_ADDR,
> --
> 1.9.0
>
David Miller - April 20, 2014, 10:19 p.m.
From: Daniel Mack <zonque@gmail.com>
Date: Wed, 16 Apr 2014 17:19:13 +0200

> Use the generic bits from genphy_config_init() instead of implementing
> the same functionality again.
> 
> Signed-off-by: Daniel Mack <zonque@gmail.com>

Applied.
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch

diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c
index bc71947..850171f 100644
--- a/drivers/net/phy/at803x.c
+++ b/drivers/net/phy/at803x.c
@@ -141,41 +141,11 @@  static int at803x_resume(struct phy_device *phydev)
 
 static int at803x_config_init(struct phy_device *phydev)
 {
-	int val;
 	int ret;
-	u32 features;
-
-	features = SUPPORTED_TP | SUPPORTED_MII | SUPPORTED_AUI |
-		   SUPPORTED_FIBRE | SUPPORTED_BNC;
-
-	val = phy_read(phydev, MII_BMSR);
-	if (val < 0)
-		return val;
-
-	if (val & BMSR_ANEGCAPABLE)
-		features |= SUPPORTED_Autoneg;
-	if (val & BMSR_100FULL)
-		features |= SUPPORTED_100baseT_Full;
-	if (val & BMSR_100HALF)
-		features |= SUPPORTED_100baseT_Half;
-	if (val & BMSR_10FULL)
-		features |= SUPPORTED_10baseT_Full;
-	if (val & BMSR_10HALF)
-		features |= SUPPORTED_10baseT_Half;
-
-	if (val & BMSR_ESTATEN) {
-		val = phy_read(phydev, MII_ESTATUS);
-		if (val < 0)
-			return val;
-
-		if (val & ESTATUS_1000_TFULL)
-			features |= SUPPORTED_1000baseT_Full;
-		if (val & ESTATUS_1000_THALF)
-			features |= SUPPORTED_1000baseT_Half;
-	}
 
-	phydev->supported = features;
-	phydev->advertising = features;
+	ret = genphy_config_init(phydev);
+	if (ret < 0)
+		return ret;
 
 	if (phydev->interface == PHY_INTERFACE_MODE_RGMII_TXID) {
 		ret = phy_write(phydev, AT803X_DEBUG_ADDR,