Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 112173
b: refs/heads/master
c: 51e2a38
h: refs/heads/master
i:
  112171: 42d8685
v: v3
  • Loading branch information
Trent Piepho authored and David S. Miller committed Oct 8, 2008
1 parent cb8cf17 commit e455f9e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 7bf6bf4803df1adc927f585168d2135fb019c698
refs/heads/master: 51e2a3846eab18711f4eb59cd0a4c33054e2980a
49 changes: 30 additions & 19 deletions trunk/drivers/net/phy/phy_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -419,21 +419,22 @@ EXPORT_SYMBOL(phy_detach);
*
* Description: Writes MII_ADVERTISE with the appropriate values,
* after sanitizing the values to make sure we only advertise
* what is supported.
* what is supported. Returns < 0 on error, 0 if the PHY's advertisement
* hasn't changed, and > 0 if it has changed.
*/
int genphy_config_advert(struct phy_device *phydev)
{
u32 advertise;
int adv;
int err;
int oldadv, adv;
int err, changed = 0;

/* Only allow advertising what
* this PHY supports */
phydev->advertising &= phydev->supported;
advertise = phydev->advertising;

/* Setup standard advertisement */
adv = phy_read(phydev, MII_ADVERTISE);
oldadv = adv = phy_read(phydev, MII_ADVERTISE);

if (adv < 0)
return adv;
Expand All @@ -453,15 +454,18 @@ int genphy_config_advert(struct phy_device *phydev)
if (advertise & ADVERTISED_Asym_Pause)
adv |= ADVERTISE_PAUSE_ASYM;

err = phy_write(phydev, MII_ADVERTISE, adv);
if (adv != oldadv) {
err = phy_write(phydev, MII_ADVERTISE, adv);

if (err < 0)
return err;
if (err < 0)
return err;
changed = 1;
}

/* Configure gigabit if it's supported */
if (phydev->supported & (SUPPORTED_1000baseT_Half |
SUPPORTED_1000baseT_Full)) {
adv = phy_read(phydev, MII_CTRL1000);
oldadv = adv = phy_read(phydev, MII_CTRL1000);

if (adv < 0)
return adv;
Expand All @@ -471,13 +475,17 @@ int genphy_config_advert(struct phy_device *phydev)
adv |= ADVERTISE_1000HALF;
if (advertise & SUPPORTED_1000baseT_Full)
adv |= ADVERTISE_1000FULL;
err = phy_write(phydev, MII_CTRL1000, adv);

if (err < 0)
return err;
if (adv != oldadv) {
err = phy_write(phydev, MII_CTRL1000, adv);

if (err < 0)
return err;
changed = 1;
}
}

return adv;
return changed;
}
EXPORT_SYMBOL(genphy_config_advert);

Expand Down Expand Up @@ -561,19 +569,22 @@ int genphy_restart_aneg(struct phy_device *phydev)
*/
int genphy_config_aneg(struct phy_device *phydev)
{
int err = 0;
int result = 0;

if (AUTONEG_ENABLE == phydev->autoneg) {
err = genphy_config_advert(phydev);
int result = genphy_config_advert(phydev);

if (err < 0)
return err;
if (result < 0) /* error */
return result;

err = genphy_restart_aneg(phydev);
/* Only restart aneg if we are advertising something different
* than we were before. */
if (result > 0)
result = genphy_restart_aneg(phydev);
} else
err = genphy_setup_forced(phydev);
result = genphy_setup_forced(phydev);

return err;
return result;
}
EXPORT_SYMBOL(genphy_config_aneg);

Expand Down

0 comments on commit e455f9e

Please sign in to comment.