return 0;
case SIOCSHWTSTAMP:
- if (phydev->drv->hwtstamp)
+ if (phydev->drv && phydev->drv->hwtstamp)
return phydev->drv->hwtstamp(phydev, ifr);
/* fall through */
{
int err;
+ if (!phydev->drv)
+ return -EIO;
+
mutex_lock(&phydev->lock);
if (AUTONEG_DISABLE == phydev->autoneg)
old_state = phydev->state;
- if (phydev->drv->link_change_notify)
+ if (phydev->drv && phydev->drv->link_change_notify)
phydev->drv->link_change_notify(phydev);
switch (phydev->state) {
*/
int phy_init_eee(struct phy_device *phydev, bool clk_stop_enable)
{
+ if (!phydev->drv)
+ return -EIO;
+
/* According to 802.3az,the EEE is supported only in full duplex-mode.
* Also EEE feature is active when core is operating with MII, GMII
* or RGMII (all kinds). Internal PHYs are also allowed to proceed and
*/
int phy_get_eee_err(struct phy_device *phydev)
{
+ if (!phydev->drv)
+ return -EIO;
+
return phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_WK_ERR, MDIO_MMD_PCS);
}
EXPORT_SYMBOL(phy_get_eee_err);
{
int val;
+ if (!phydev->drv)
+ return -EIO;
+
/* Get Supported EEE */
val = phy_read_mmd_indirect(phydev, MDIO_PCS_EEE_ABLE, MDIO_MMD_PCS);
if (val < 0)
{
int val = ethtool_adv_to_mmd_eee_adv_t(data->advertised);
+ if (!phydev->drv)
+ return -EIO;
+
/* Mask prohibited EEE modes */
val &= ~phydev->eee_broken_modes;
int phy_ethtool_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
{
- if (phydev->drv->set_wol)
+ if (phydev->drv && phydev->drv->set_wol)
return phydev->drv->set_wol(phydev, wol);
return -EOPNOTSUPP;
void phy_ethtool_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol)
{
- if (phydev->drv->get_wol)
+ if (phydev->drv && phydev->drv->get_wol)
phydev->drv->get_wol(phydev, wol);
}
EXPORT_SYMBOL(phy_ethtool_get_wol);
if (!phydev)
return -ENODEV;
+ if (!phydev->drv)
+ return -EIO;
+
return genphy_restart_aneg(phydev);
}
EXPORT_SYMBOL(phy_ethtool_nway_reset);
if (wol.wolopts)
return -EBUSY;
- if (phydrv->suspend)
+ if (phydev->drv && phydrv->suspend)
ret = phydrv->suspend(phydev);
if (ret)
struct phy_driver *phydrv = to_phy_driver(phydev->mdio.dev.driver);
int ret = 0;
- if (phydrv->resume)
+ if (phydev->drv && phydrv->resume)
ret = phydrv->resume(phydev);
if (ret)
phydev->state = PHY_DOWN;
mutex_unlock(&phydev->lock);
- if (phydev->drv->remove)
+ if (phydev->drv && phydev->drv->remove)
phydev->drv->remove(phydev);
phydev->drv = NULL;