diff options
Diffstat (limited to 'drivers/net/phy/phy_device.c')
| -rw-r--r-- | drivers/net/phy/phy_device.c | 38 |
1 files changed, 25 insertions, 13 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index e11b03b2b25a..55bc24b234e3 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c | |||
| @@ -227,8 +227,8 @@ struct phy_device * get_phy_device(struct mii_bus *bus, int addr) | |||
| 227 | if (r) | 227 | if (r) |
| 228 | return ERR_PTR(r); | 228 | return ERR_PTR(r); |
| 229 | 229 | ||
| 230 | /* If the phy_id is all Fs, there is no device there */ | 230 | /* If the phy_id is all Fs or all 0s, there is no device there */ |
| 231 | if (0xffffffff == phy_id) | 231 | if ((0xffff == phy_id) || (0x00 == phy_id)) |
| 232 | return NULL; | 232 | return NULL; |
| 233 | 233 | ||
| 234 | dev = phy_device_create(bus, addr, phy_id); | 234 | dev = phy_device_create(bus, addr, phy_id); |
| @@ -564,20 +564,32 @@ EXPORT_SYMBOL(genphy_restart_aneg); | |||
| 564 | */ | 564 | */ |
| 565 | int genphy_config_aneg(struct phy_device *phydev) | 565 | int genphy_config_aneg(struct phy_device *phydev) |
| 566 | { | 566 | { |
| 567 | int result = 0; | 567 | int result; |
| 568 | 568 | ||
| 569 | if (AUTONEG_ENABLE == phydev->autoneg) { | 569 | if (AUTONEG_ENABLE != phydev->autoneg) |
| 570 | int result = genphy_config_advert(phydev); | 570 | return genphy_setup_forced(phydev); |
| 571 | |||
| 572 | result = genphy_config_advert(phydev); | ||
| 573 | |||
| 574 | if (result < 0) /* error */ | ||
| 575 | return result; | ||
| 571 | 576 | ||
| 572 | if (result < 0) /* error */ | 577 | if (result == 0) { |
| 573 | return result; | 578 | /* Advertisment hasn't changed, but maybe aneg was never on to |
| 579 | * begin with? Or maybe phy was isolated? */ | ||
| 580 | int ctl = phy_read(phydev, MII_BMCR); | ||
| 581 | |||
| 582 | if (ctl < 0) | ||
| 583 | return ctl; | ||
| 584 | |||
| 585 | if (!(ctl & BMCR_ANENABLE) || (ctl & BMCR_ISOLATE)) | ||
| 586 | result = 1; /* do restart aneg */ | ||
| 587 | } | ||
| 574 | 588 | ||
| 575 | /* Only restart aneg if we are advertising something different | 589 | /* Only restart aneg if we are advertising something different |
| 576 | * than we were before. */ | 590 | * than we were before. */ |
| 577 | if (result > 0) | 591 | if (result > 0) |
| 578 | result = genphy_restart_aneg(phydev); | 592 | result = genphy_restart_aneg(phydev); |
| 579 | } else | ||
| 580 | result = genphy_setup_forced(phydev); | ||
| 581 | 593 | ||
| 582 | return result; | 594 | return result; |
| 583 | } | 595 | } |
