diff options
author | David S. Miller <davem@davemloft.net> | 2020-01-20 10:43:24 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2020-01-20 10:43:24 +0100 |
commit | 794eee259e8e1a7e6f31417ec8f6fa809597bb24 (patch) | |
tree | 8ed37adbc7ebc589264b473a90e3051d599f6fee | |
parent | 4262c38dc42e092987f41cb1695240ac7dab86a9 (diff) | |
parent | df007186488e33716ccf0c01f93cc5fe1ef91847 (diff) |
Merge branch 'net-phy-add-generic-ndo_do_ioctl-handler-phy_do_ioctl'
Heiner Kallweit says:
====================
net: phy: add generic ndo_do_ioctl handler phy_do_ioctl
A number of network drivers has the same glue code to use phy_mii_ioctl
as ndo_do_ioctl handler. So let's add such a generic ndo_do_ioctl
handler to phylib. As first user convert r8169.
====================
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/realtek/r8169_main.c | 12 | ||||
-rw-r--r-- | drivers/net/phy/phy.c | 15 | ||||
-rw-r--r-- | include/linux/phy.h | 1 |
3 files changed, 17 insertions, 11 deletions
diff --git a/drivers/net/ethernet/realtek/r8169_main.c b/drivers/net/ethernet/realtek/r8169_main.c index 6d699df7d27f..175f951b6547 100644 --- a/drivers/net/ethernet/realtek/r8169_main.c +++ b/drivers/net/ethernet/realtek/r8169_main.c @@ -2298,16 +2298,6 @@ static int rtl_set_mac_address(struct net_device *dev, void *p) return 0; } -static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) -{ - struct rtl8169_private *tp = netdev_priv(dev); - - if (!netif_running(dev)) - return -ENODEV; - - return phy_mii_ioctl(tp->phydev, ifr, cmd); -} - static void rtl_wol_suspend_quirk(struct rtl8169_private *tp) { switch (tp->mac_version) { @@ -5168,7 +5158,7 @@ static const struct net_device_ops rtl_netdev_ops = { .ndo_fix_features = rtl8169_fix_features, .ndo_set_features = rtl8169_set_features, .ndo_set_mac_address = rtl_set_mac_address, - .ndo_do_ioctl = rtl8169_ioctl, + .ndo_do_ioctl = phy_do_ioctl, .ndo_set_rx_mode = rtl_set_rx_mode, #ifdef CONFIG_NET_POLL_CONTROLLER .ndo_poll_controller = rtl8169_netpoll, diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 541ed01496bf..da05b3480abb 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -432,6 +432,21 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd) } EXPORT_SYMBOL(phy_mii_ioctl); +/** + * phy_do_ioctl - generic ndo_do_ioctl implementation + * @dev: the net_device struct + * @ifr: &struct ifreq for socket ioctl's + * @cmd: ioctl cmd to execute + */ +int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) +{ + if (!netif_running(dev) || !dev->phydev) + return -ENODEV; + + return phy_mii_ioctl(dev->phydev, ifr, cmd); +} +EXPORT_SYMBOL(phy_do_ioctl); + void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies) { mod_delayed_work(system_power_efficient_wq, &phydev->state_queue, diff --git a/include/linux/phy.h b/include/linux/phy.h index 99a87f02667f..be6b3a1b03da 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1242,6 +1242,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev, int phy_ethtool_ksettings_set(struct phy_device *phydev, const struct ethtool_link_ksettings *cmd); int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd); +int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd); void phy_request_interrupt(struct phy_device *phydev); void phy_free_interrupt(struct phy_device *phydev); void phy_print_status(struct phy_device *phydev); |