Skip to content

Commit bbbf843

Browse files
hkallweitdavem330
authored andcommitted
net: phy: add new version of phy_do_ioctl
Add a new version of phy_do_ioctl that doesn't check whether net_device is running. It will typically be used if suitable drivers attach the PHY in probe already. Signed-off-by: Heiner Kallweit <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3231e5d commit bbbf843

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

drivers/net/phy/phy.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -433,18 +433,28 @@ int phy_mii_ioctl(struct phy_device *phydev, struct ifreq *ifr, int cmd)
433433
EXPORT_SYMBOL(phy_mii_ioctl);
434434

435435
/**
436-
* phy_do_ioctl_running - generic ndo_do_ioctl implementation
436+
* phy_do_ioctl - generic ndo_do_ioctl implementation
437437
* @dev: the net_device struct
438438
* @ifr: &struct ifreq for socket ioctl's
439439
* @cmd: ioctl cmd to execute
440440
*/
441-
int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
441+
int phy_do_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
442442
{
443-
if (!netif_running(dev) || !dev->phydev)
443+
if (!dev->phydev)
444444
return -ENODEV;
445445

446446
return phy_mii_ioctl(dev->phydev, ifr, cmd);
447447
}
448+
EXPORT_SYMBOL(phy_do_ioctl);
449+
450+
/* same as phy_do_ioctl, but ensures that net_device is running */
451+
int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd)
452+
{
453+
if (!netif_running(dev))
454+
return -ENODEV;
455+
456+
return phy_do_ioctl(dev, ifr, cmd);
457+
}
448458
EXPORT_SYMBOL(phy_do_ioctl_running);
449459

450460
void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies)

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
int phy_do_ioctl_running(struct net_device *dev, struct ifreq *ifr, int cmd);
12461247
void phy_request_interrupt(struct phy_device *phydev);
12471248
void phy_free_interrupt(struct phy_device *phydev);

0 commit comments

Comments
 (0)