mirror of
https://github.com/torvalds/linux.git
synced 2024-11-22 12:11:40 +00:00
net: promote SIOCSHWTSTAMP and SIOCGHWTSTAMP ioctls to dedicated handlers
DSA does not want to intercept all ioctls handled by dev_eth_ioctl(),
only SIOCSHWTSTAMP. This can be seen from commit f685e609a3
("net:
dsa: Deny PTP on master if switch supports it"). However, the way in
which the dsa_ndo_eth_ioctl() is called would suggest otherwise.
Split the handling of SIOCSHWTSTAMP and SIOCGHWTSTAMP ioctls into
separate case statements of dev_ifsioc(), and make each one call its own
sub-function. This also removes the dsa_ndo_eth_ioctl() call from
dev_eth_ioctl(), which from now on exclusively handles PHY ioctls.
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
1193db2a55
commit
4ee58e1e56
@ -246,20 +246,34 @@ static int dev_eth_ioctl(struct net_device *dev,
|
||||
struct ifreq *ifr, unsigned int cmd)
|
||||
{
|
||||
const struct net_device_ops *ops = dev->netdev_ops;
|
||||
|
||||
if (!ops->ndo_eth_ioctl)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (!netif_device_present(dev))
|
||||
return -ENODEV;
|
||||
|
||||
return ops->ndo_eth_ioctl(dev, ifr, cmd);
|
||||
}
|
||||
|
||||
static int dev_get_hwtstamp(struct net_device *dev, struct ifreq *ifr)
|
||||
{
|
||||
return dev_eth_ioctl(dev, ifr, SIOCGHWTSTAMP);
|
||||
}
|
||||
|
||||
static int dev_set_hwtstamp(struct net_device *dev, struct ifreq *ifr)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = dsa_ndo_eth_ioctl(dev, ifr, cmd);
|
||||
err = net_hwtstamp_validate(ifr);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = dsa_ndo_eth_ioctl(dev, ifr, SIOCSHWTSTAMP);
|
||||
if (err != -EOPNOTSUPP)
|
||||
return err;
|
||||
|
||||
if (ops->ndo_eth_ioctl) {
|
||||
if (netif_device_present(dev))
|
||||
err = ops->ndo_eth_ioctl(dev, ifr, cmd);
|
||||
else
|
||||
err = -ENODEV;
|
||||
}
|
||||
|
||||
return err;
|
||||
return dev_eth_ioctl(dev, ifr, SIOCSHWTSTAMP);
|
||||
}
|
||||
|
||||
static int dev_siocbond(struct net_device *dev,
|
||||
@ -395,12 +409,11 @@ static int dev_ifsioc(struct net *net, struct ifreq *ifr, void __user *data,
|
||||
return dev_siocdevprivate(dev, ifr, data, cmd);
|
||||
|
||||
case SIOCSHWTSTAMP:
|
||||
err = net_hwtstamp_validate(ifr);
|
||||
if (err)
|
||||
return err;
|
||||
fallthrough;
|
||||
return dev_set_hwtstamp(dev, ifr);
|
||||
|
||||
case SIOCGHWTSTAMP:
|
||||
return dev_get_hwtstamp(dev, ifr);
|
||||
|
||||
case SIOCGMIIPHY:
|
||||
case SIOCGMIIREG:
|
||||
case SIOCSMIIREG:
|
||||
|
Loading…
Reference in New Issue
Block a user