Skip to contentSkip to conversation

enetc: add ioctl() support for PHY-related ops

PATCH Applied Michael Walle 3 participants 3 messages Nov 7, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 enetc: add ioctl() support for PHY-related ops

If there is an attached PHY try to handle the requested ioctl with its handler, which allows the userspace to access PHY registers, for example. This will make mii-diag and similar tools work.

---
 drivers/net/ethernet/freescale/enetc/enetc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/enetc/enetc.c +4 -1
index b6ff89307409..25af207f1962 100644
@@ -1599,7 +1599,10 @@ int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
 	if (cmd == SIOCGHWTSTAMP)
 		return enetc_hwtstamp_get(ndev, rq);
 #endif
-	return -EINVAL;
+
+	if (!ndev->phydev)
+		return -EINVAL;
+	return phy_mii_ioctl(ndev->phydev, rq, cmd);
 }
 
 int enetc_alloc_msix(struct enetc_ndev_priv *priv)
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Michael Walle

If there is an attached PHY try to handle the requested ioctl with its handler, which allows the userspace to access PHY registers, for example. This will make mii-diag and similar tools work.

---
 drivers/net/ethernet/freescale/enetc/enetc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/ethernet/freescale/enetc/enetc.c +0 -0
index b6ff89307409..25af207f1962 100644

drivers/net/ethernet/freescale/enetc/enetc.c int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) · line 1604

Quoted 7 lines
drivers/net/ethernet/freescale/enetc/enetc.c +3 -1
@@ -1599,7 +1599,10 @@ int enetc_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
 	if (cmd == SIOCGHWTSTAMP)
 		return enetc_hwtstamp_get(ndev, rq);
 #endif
-	return -EINVAL;
+
+	if (!ndev->phydev)
+		return -EINVAL;

Hi Michael

I think EOPNOTSUPP is normal. Yes, you are just moving around what was there before, but you could make this improvement as well.

If you don't want to:

Andrew