Skip to content

Commit 794eee2

Browse files
committed
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 <[email protected]>
2 parents 4262c38 + df00718 commit 794eee2

File tree

3 files changed

+17
-11
lines changed

3 files changed

+17
-11
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2298,16 +2298,6 @@ static int rtl_set_mac_address(struct net_device *dev, void *p)
22982298
return 0;
22992299
}
23002300

2301-
static int rtl8169_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
2302-
{
2303-
struct rtl8169_private *tp = netdev_priv(dev);
2304-
2305-
if (!netif_running(dev))
2306-
return -ENODEV;
2307-
2308-
return phy_mii_ioctl(tp->phydev, ifr, cmd);
2309-
}
2310-
23112301
static void rtl_wol_suspend_quirk(struct rtl8169_private *tp)
23122302
{
23132303
switch (tp->mac_version) {
@@ -5168,7 +5158,7 @@ static const struct net_device_ops rtl_netdev_ops = {
51685158
.ndo_fix_features = rtl8169_fix_features,
51695159
.ndo_set_features = rtl8169_set_features,
51705160
.ndo_set_mac_address = rtl_set_mac_address,
5171-
.ndo_do_ioctl = rtl8169_ioctl,
5161+
.ndo_do_ioctl = phy_do_ioctl,
51725162
.ndo_set_rx_mode = rtl_set_rx_mode,
51735163
#ifdef CONFIG_NET_POLL_CONTROLLER
51745164
.ndo_poll_controller = rtl8169_netpoll,

drivers/net/phy/phy.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,21 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
432432
}
433433
EXPORT_SYMBOL(phy_mii_ioctl);
434434

435+
/**
436+
* phy_do_ioctl - generic ndo_do_ioctl implementation
437+
* @dev: the net_device struct
438+
* @ifr: &struct ifreq for socket ioctl's
439+
* @cmd: ioctl cmd to execute
440+
*/
441+
int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
442+
{
443+
if (!netif_running(dev) || !dev->phydev)
444+
return -ENODEV;
445+
446+
return phy_mii_ioctl(dev->phydev, ifr, cmd);
447+
}
448+
EXPORT_SYMBOL(phy_do_ioctl);
449+
435450
void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)
436451
{
437452
mod_delayed_work(system_power_efficient_wq, &phydev->state_queue,

include/linux/phy.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1242,6 +1242,7 @@ void phy_ethtool_ksettings_get(struct phy_device *phydev,
12421242
int phy_ethtool_ksettings_set(struct phy_device *phydev,
12431243
const struct ethtool_link_ksettings *cmd);
12441244
int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd);
1245+
int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd);
12451246
void phy_request_interrupt(struct phy_device *phydev);
12461247
void phy_free_interrupt(struct phy_device *phydev);
12471248
void phy_print_status(struct phy_device *phydev);

0 commit comments

Comments
 (0)