提交 2186f6ee 编写于 作者: P Philippe Reynes 提交者: David S. Miller

net: ethernet: marvell: pxa168_eth: use phy_ethtool_{get|set}_link_ksettings

There are two generics functions phy_ethtool_{get|set}_link_ksettings,
so we can use them instead of defining the same code in the driver.
Signed-off-by: NPhilippe Reynes <tremyfr@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 7d321845
...@@ -274,8 +274,8 @@ enum hash_table_entry { ...@@ -274,8 +274,8 @@ enum hash_table_entry {
HASH_ENTRY_RECEIVE_DISCARD_BIT = 2 HASH_ENTRY_RECEIVE_DISCARD_BIT = 2
}; };
static int pxa168_get_settings(struct net_device *dev, struct ethtool_cmd *cmd); static int pxa168_get_link_ksettings(struct net_device *dev,
static int pxa168_set_settings(struct net_device *dev, struct ethtool_cmd *cmd); struct ethtool_link_ksettings *cmd);
static int pxa168_init_hw(struct pxa168_eth_private *pep); static int pxa168_init_hw(struct pxa168_eth_private *pep);
static int pxa168_init_phy(struct net_device *dev); static int pxa168_init_phy(struct net_device *dev);
static void eth_port_reset(struct net_device *dev); static void eth_port_reset(struct net_device *dev);
...@@ -971,7 +971,7 @@ static void pxa168_eth_adjust_link(struct net_device *dev) ...@@ -971,7 +971,7 @@ static void pxa168_eth_adjust_link(struct net_device *dev)
static int pxa168_init_phy(struct net_device *dev) static int pxa168_init_phy(struct net_device *dev)
{ {
struct pxa168_eth_private *pep = netdev_priv(dev); struct pxa168_eth_private *pep = netdev_priv(dev);
struct ethtool_cmd cmd; struct ethtool_link_ksettings cmd;
struct phy_device *phy = NULL; struct phy_device *phy = NULL;
int err; int err;
...@@ -987,20 +987,21 @@ static int pxa168_init_phy(struct net_device *dev) ...@@ -987,20 +987,21 @@ static int pxa168_init_phy(struct net_device *dev)
if (err) if (err)
return err; return err;
err = pxa168_get_settings(dev, &cmd); err = pxa168_get_link_ksettings(dev, &cmd);
if (err) if (err)
return err; return err;
cmd.phy_address = pep->phy_addr; cmd.base.phy_address = pep->phy_addr;
cmd.speed = pep->phy_speed; cmd.base.speed = pep->phy_speed;
cmd.duplex = pep->phy_duplex; cmd.base.duplex = pep->phy_duplex;
cmd.advertising = PHY_BASIC_FEATURES; ethtool_convert_legacy_u32_to_link_mode(cmd.link_modes.advertising,
cmd.autoneg = AUTONEG_ENABLE; PHY_BASIC_FEATURES);
cmd.base.autoneg = AUTONEG_ENABLE;
if (cmd.speed != 0) if (cmd.base.speed != 0)
cmd.autoneg = AUTONEG_DISABLE; cmd.base.autoneg = AUTONEG_DISABLE;
return pxa168_set_settings(dev, &cmd); return phy_ethtool_set_link_ksettings(dev, &cmd);
} }
static int pxa168_init_hw(struct pxa168_eth_private *pep) static int pxa168_init_hw(struct pxa168_eth_private *pep)
...@@ -1372,22 +1373,18 @@ static int pxa168_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr, ...@@ -1372,22 +1373,18 @@ static int pxa168_eth_do_ioctl(struct net_device *dev, struct ifreq *ifr,
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int pxa168_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int pxa168_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{ {
int err; int err;
err = phy_read_status(dev->phydev); err = phy_read_status(dev->phydev);
if (err == 0) if (err == 0)
err = phy_ethtool_gset(dev->phydev, cmd); err = phy_ethtool_ksettings_get(dev->phydev, cmd);
return err; return err;
} }
static int pxa168_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{
return phy_ethtool_sset(dev->phydev, cmd);
}
static void pxa168_get_drvinfo(struct net_device *dev, static void pxa168_get_drvinfo(struct net_device *dev,
struct ethtool_drvinfo *info) struct ethtool_drvinfo *info)
{ {
...@@ -1398,11 +1395,11 @@ static void pxa168_get_drvinfo(struct net_device *dev, ...@@ -1398,11 +1395,11 @@ static void pxa168_get_drvinfo(struct net_device *dev,
} }
static const struct ethtool_ops pxa168_ethtool_ops = { static const struct ethtool_ops pxa168_ethtool_ops = {
.get_settings = pxa168_get_settings,
.set_settings = pxa168_set_settings,
.get_drvinfo = pxa168_get_drvinfo, .get_drvinfo = pxa168_get_drvinfo,
.get_link = ethtool_op_get_link, .get_link = ethtool_op_get_link,
.get_ts_info = ethtool_op_get_ts_info, .get_ts_info = ethtool_op_get_ts_info,
.get_link_ksettings = pxa168_get_link_ksettings,
.set_link_ksettings = phy_ethtool_set_link_ksettings,
}; };
static const struct net_device_ops pxa168_eth_netdev_ops = { static const struct net_device_ops pxa168_eth_netdev_ops = {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册