diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index 7c5e8c1e937078e90bcf33218988ae2405910f3b..edb8b9ab827fb2a7d42d0f32908b5c796dae8a74 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig @@ -9,6 +9,7 @@ menuconfig MDIO_DEVICE config MDIO_BUS tristate + default m if PHYLIB=m default MDIO_DEVICE help This internal symbol is used for link time dependencies and it @@ -170,7 +171,7 @@ config PHYLINK autonegotiation modes. menuconfig PHYLIB - bool "PHY Device support and infrastructure" + tristate "PHY Device support and infrastructure" depends on NETDEVICES select MDIO_DEVICE help diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index a98ed12c00095366fa141baaf9d2db577fb89733..05c1e8ef15e61d26beac3542a0ab2836cab6c3a6 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -1277,51 +1277,3 @@ int phy_ethtool_nway_reset(struct net_device *ndev) return phy_restart_aneg(phydev); } EXPORT_SYMBOL(phy_ethtool_nway_reset); - -int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data) -{ - if (!phydev->drv) - return -EIO; - - mutex_lock(&phydev->lock); - phydev->drv->get_strings(phydev, data); - mutex_unlock(&phydev->lock); - - return 0; -} -EXPORT_SYMBOL(phy_ethtool_get_strings); - -int phy_ethtool_get_sset_count(struct phy_device *phydev) -{ - int ret; - - if (!phydev->drv) - return -EIO; - - if (phydev->drv->get_sset_count && - phydev->drv->get_strings && - phydev->drv->get_stats) { - mutex_lock(&phydev->lock); - ret = phydev->drv->get_sset_count(phydev); - mutex_unlock(&phydev->lock); - - return ret; - } - - return -EOPNOTSUPP; -} -EXPORT_SYMBOL(phy_ethtool_get_sset_count); - -int phy_ethtool_get_stats(struct phy_device *phydev, - struct ethtool_stats *stats, u64 *data) -{ - if (!phydev->drv) - return -EIO; - - mutex_lock(&phydev->lock); - phydev->drv->get_stats(phydev, stats, data); - mutex_unlock(&phydev->lock); - - return 0; -} -EXPORT_SYMBOL(phy_ethtool_get_stats); diff --git a/include/linux/phy.h b/include/linux/phy.h index 6ca81395c5456ca90a0ebfefbfbb12771be6f28e..073235e704427c3e1238f4cfed1a97574f8193b3 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1066,27 +1066,53 @@ int phy_ethtool_nway_reset(struct net_device *ndev); #if IS_ENABLED(CONFIG_PHYLIB) int __init mdio_bus_init(void); void mdio_bus_exit(void); -int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data); -int phy_ethtool_get_sset_count(struct phy_device *phydev); -int phy_ethtool_get_stats(struct phy_device *phydev, - struct ethtool_stats *stats, u64 *data); -#else -int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data) +#endif + +/* Inline function for use within net/core/ethtool.c (built-in) */ +static inline int phy_ethtool_get_strings(struct phy_device *phydev, u8 *data) { - return -EOPNOTSUPP; + if (!phydev->drv) + return -EIO; + + mutex_lock(&phydev->lock); + phydev->drv->get_strings(phydev, data); + mutex_unlock(&phydev->lock); + + return 0; } -int phy_ethtool_get_sset_count(struct phy_device *phydev) +static inline int phy_ethtool_get_sset_count(struct phy_device *phydev) { + int ret; + + if (!phydev->drv) + return -EIO; + + if (phydev->drv->get_sset_count && + phydev->drv->get_strings && + phydev->drv->get_stats) { + mutex_lock(&phydev->lock); + ret = phydev->drv->get_sset_count(phydev); + mutex_unlock(&phydev->lock); + + return ret; + } + return -EOPNOTSUPP; } -int phy_ethtool_get_stats(struct phy_device *phydev, - struct ethtool_stats *stats, u64 *data) +static inline int phy_ethtool_get_stats(struct phy_device *phydev, + struct ethtool_stats *stats, u64 *data) { - return -EOPNOTSUPP; + if (!phydev->drv) + return -EIO; + + mutex_lock(&phydev->lock); + phydev->drv->get_stats(phydev, stats, data); + mutex_unlock(&phydev->lock); + + return 0; } -#endif extern struct bus_type mdio_bus_type;