net: mscc: use the PHY MII ioctl interface when possible
authorAntoine Tenart <antoine.tenart@bootlin.com>
Tue, 26 May 2020 15:01:48 +0000 (17:01 +0200)
committerDavid S. Miller <davem@davemloft.net>
Wed, 27 May 2020 21:54:31 +0000 (14:54 -0700)
Allow ioctl to be implemented by the PHY, when a PHY is attached to the
Ocelot switch. In case the ioctl is a request to set or get the hardware
timestamp, use the Ocelot switch implementation for now.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/mscc/ocelot.c

index e621c4c3ee8662c248172412f33b27806630f8fe..2151c08a57c78e84d1d0e3e38ab5fbf779d6d1dc 100644 (file)
@@ -1204,18 +1204,16 @@ static int ocelot_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
        struct ocelot *ocelot = priv->port.ocelot;
        int port = priv->chip_port;
 
-       /* The function is only used for PTP operations for now */
-       if (!ocelot->ptp)
-               return -EOPNOTSUPP;
-
-       switch (cmd) {
-       case SIOCSHWTSTAMP:
-               return ocelot_hwstamp_set(ocelot, port, ifr);
-       case SIOCGHWTSTAMP:
-               return ocelot_hwstamp_get(ocelot, port, ifr);
-       default:
-               return -EOPNOTSUPP;
+       if (ocelot->ptp) {
+               switch (cmd) {
+               case SIOCSHWTSTAMP:
+                       return ocelot_hwstamp_set(ocelot, port, ifr);
+               case SIOCGHWTSTAMP:
+                       return ocelot_hwstamp_get(ocelot, port, ifr);
+               }
        }
+
+       return phy_mii_ioctl(dev->phydev, ifr, cmd);
 }
 
 static const struct net_device_ops ocelot_port_netdev_ops = {