mirror of
https://github.com/torvalds/linux.git
synced 2024-12-12 14:12:51 +00:00
ethtool: switch back from ethtool_keee to ethtool_eee for ioctl
In order to later extend struct ethtool_keee, we have to decouple it from the userspace format represented by struct ethtool_eee. Therefore switch back to struct ethtool_eee, representing the userspace format, and add conversion between ethtool_eee and ethtool_keee. Struct ethtool_keee will be changed in follow-up patches, therefore don't do a *keee = *eee here. Member cmd isn't copied, because it's not used, and we'll remove it in the next patch of this series. In addition omit setting cmd to ETHTOOL_GEEE in the ioctl response, userspace ethtool isn't interested in it. Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com> Reviewed-by: Andrew Lunn <andrew@lunn.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
d80a523353
commit
0b3100bc8f
@ -1508,22 +1508,50 @@ static int ethtool_set_wol(struct net_device *dev, char __user *useraddr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void eee_to_keee(struct ethtool_keee *keee,
|
||||||
|
const struct ethtool_eee *eee)
|
||||||
|
{
|
||||||
|
memset(keee, 0, sizeof(*keee));
|
||||||
|
|
||||||
|
keee->supported = eee->supported;
|
||||||
|
keee->advertised = eee->advertised;
|
||||||
|
keee->lp_advertised = eee->lp_advertised;
|
||||||
|
keee->eee_active = eee->eee_active;
|
||||||
|
keee->eee_enabled = eee->eee_enabled;
|
||||||
|
keee->tx_lpi_enabled = eee->tx_lpi_enabled;
|
||||||
|
keee->tx_lpi_timer = eee->tx_lpi_timer;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void keee_to_eee(struct ethtool_eee *eee,
|
||||||
|
const struct ethtool_keee *keee)
|
||||||
|
{
|
||||||
|
memset(eee, 0, sizeof(*eee));
|
||||||
|
|
||||||
|
eee->supported = keee->supported;
|
||||||
|
eee->advertised = keee->advertised;
|
||||||
|
eee->lp_advertised = keee->lp_advertised;
|
||||||
|
eee->eee_active = keee->eee_active;
|
||||||
|
eee->eee_enabled = keee->eee_enabled;
|
||||||
|
eee->tx_lpi_enabled = keee->tx_lpi_enabled;
|
||||||
|
eee->tx_lpi_timer = keee->tx_lpi_timer;
|
||||||
|
}
|
||||||
|
|
||||||
static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
|
static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
|
||||||
{
|
{
|
||||||
struct ethtool_keee edata;
|
struct ethtool_keee keee;
|
||||||
|
struct ethtool_eee eee;
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!dev->ethtool_ops->get_eee)
|
if (!dev->ethtool_ops->get_eee)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
memset(&edata, 0, sizeof(struct ethtool_keee));
|
memset(&keee, 0, sizeof(keee));
|
||||||
edata.cmd = ETHTOOL_GEEE;
|
rc = dev->ethtool_ops->get_eee(dev, &keee);
|
||||||
rc = dev->ethtool_ops->get_eee(dev, &edata);
|
|
||||||
|
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
if (copy_to_user(useraddr, &edata, sizeof(edata)))
|
keee_to_eee(&eee, &keee);
|
||||||
|
if (copy_to_user(useraddr, &eee, sizeof(eee)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -1531,16 +1559,18 @@ static int ethtool_get_eee(struct net_device *dev, char __user *useraddr)
|
|||||||
|
|
||||||
static int ethtool_set_eee(struct net_device *dev, char __user *useraddr)
|
static int ethtool_set_eee(struct net_device *dev, char __user *useraddr)
|
||||||
{
|
{
|
||||||
struct ethtool_keee edata;
|
struct ethtool_keee keee;
|
||||||
|
struct ethtool_eee eee;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!dev->ethtool_ops->set_eee)
|
if (!dev->ethtool_ops->set_eee)
|
||||||
return -EOPNOTSUPP;
|
return -EOPNOTSUPP;
|
||||||
|
|
||||||
if (copy_from_user(&edata, useraddr, sizeof(edata)))
|
if (copy_from_user(&eee, useraddr, sizeof(eee)))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
|
|
||||||
ret = dev->ethtool_ops->set_eee(dev, &edata);
|
eee_to_keee(&keee, &eee);
|
||||||
|
ret = dev->ethtool_ops->set_eee(dev, &keee);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ethtool_notify(dev, ETHTOOL_MSG_EEE_NTF, NULL);
|
ethtool_notify(dev, ETHTOOL_MSG_EEE_NTF, NULL);
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user