phylib: Properly reinitialize PHYs after hibernation

Since hibernation assumes power loss, we should fully reinitialize
PHYs (including platform fixups), as if PHYs were just attached.

This patch factors phy_init_hw() out of phy_attach_direct(), then
converts mdio_bus to dev_pm_ops and adds an appropriate restore()
callback.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Anton Vorontsov 2009-12-30 08:23:30 +00:00 committed by David S. Miller
parent 541cd3ee00
commit 2f5cb43406
3 changed files with 59 additions and 22 deletions

View file

@ -378,6 +378,20 @@ void phy_disconnect(struct phy_device *phydev)
}
EXPORT_SYMBOL(phy_disconnect);
int phy_init_hw(struct phy_device *phydev)
{
int ret;
if (!phydev->drv || !phydev->drv->config_init)
return 0;
ret = phy_scan_fixups(phydev);
if (ret < 0)
return ret;
return phydev->drv->config_init(phydev);
}
/**
* phy_attach_direct - attach a network device to a given PHY device pointer
* @dev: network device to attach
@ -425,21 +439,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev,
/* Do initial configuration here, now that
* we have certain key parameters
* (dev_flags and interface) */
if (phydev->drv->config_init) {
int err;
err = phy_scan_fixups(phydev);
if (err < 0)
return err;
err = phydev->drv->config_init(phydev);
if (err < 0)
return err;
}
return 0;
return phy_init_hw(phydev);
}
EXPORT_SYMBOL(phy_attach_direct);