提交 86bc5ed6 编写于 作者: P Philippe Reynes 提交者: David S. Miller

net: ethernet: octeon: use phydev from struct net_device

The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phydev in the private structure, and update the driver to use the
one contained in struct net_device.
Signed-off-by: NPhilippe Reynes <tremyfr@gmail.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 11de8e62
...@@ -36,36 +36,30 @@ static void cvm_oct_get_drvinfo(struct net_device *dev, ...@@ -36,36 +36,30 @@ static void cvm_oct_get_drvinfo(struct net_device *dev,
static int cvm_oct_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int cvm_oct_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{ {
struct octeon_ethernet *priv = netdev_priv(dev); if (dev->phydev)
return phy_ethtool_gset(dev->phydev, cmd);
if (priv->phydev)
return phy_ethtool_gset(priv->phydev, cmd);
return -EINVAL; return -EINVAL;
} }
static int cvm_oct_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) static int cvm_oct_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
{ {
struct octeon_ethernet *priv = netdev_priv(dev);
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
if (priv->phydev) if (dev->phydev)
return phy_ethtool_sset(priv->phydev, cmd); return phy_ethtool_sset(dev->phydev, cmd);
return -EINVAL; return -EINVAL;
} }
static int cvm_oct_nway_reset(struct net_device *dev) static int cvm_oct_nway_reset(struct net_device *dev)
{ {
struct octeon_ethernet *priv = netdev_priv(dev);
if (!capable(CAP_NET_ADMIN)) if (!capable(CAP_NET_ADMIN))
return -EPERM; return -EPERM;
if (priv->phydev) if (dev->phydev)
return phy_start_aneg(priv->phydev); return phy_start_aneg(dev->phydev);
return -EINVAL; return -EINVAL;
} }
...@@ -88,15 +82,13 @@ const struct ethtool_ops cvm_oct_ethtool_ops = { ...@@ -88,15 +82,13 @@ const struct ethtool_ops cvm_oct_ethtool_ops = {
*/ */
int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
struct octeon_ethernet *priv = netdev_priv(dev);
if (!netif_running(dev)) if (!netif_running(dev))
return -EINVAL; return -EINVAL;
if (!priv->phydev) if (!dev->phydev)
return -EINVAL; return -EINVAL;
return phy_mii_ioctl(priv->phydev, rq, cmd); return phy_mii_ioctl(dev->phydev, rq, cmd);
} }
void cvm_oct_note_carrier(struct octeon_ethernet *priv, void cvm_oct_note_carrier(struct octeon_ethernet *priv,
...@@ -119,9 +111,9 @@ void cvm_oct_adjust_link(struct net_device *dev) ...@@ -119,9 +111,9 @@ void cvm_oct_adjust_link(struct net_device *dev)
cvmx_helper_link_info_t link_info; cvmx_helper_link_info_t link_info;
link_info.u64 = 0; link_info.u64 = 0;
link_info.s.link_up = priv->phydev->link ? 1 : 0; link_info.s.link_up = dev->phydev->link ? 1 : 0;
link_info.s.full_duplex = priv->phydev->duplex ? 1 : 0; link_info.s.full_duplex = dev->phydev->duplex ? 1 : 0;
link_info.s.speed = priv->phydev->speed; link_info.s.speed = dev->phydev->speed;
priv->link_info = link_info.u64; priv->link_info = link_info.u64;
/* /*
...@@ -130,8 +122,8 @@ void cvm_oct_adjust_link(struct net_device *dev) ...@@ -130,8 +122,8 @@ void cvm_oct_adjust_link(struct net_device *dev)
if (priv->poll) if (priv->poll)
priv->poll(dev); priv->poll(dev);
if (priv->last_link != priv->phydev->link) { if (priv->last_link != dev->phydev->link) {
priv->last_link = priv->phydev->link; priv->last_link = dev->phydev->link;
cvmx_helper_link_set(priv->port, link_info); cvmx_helper_link_set(priv->port, link_info);
cvm_oct_note_carrier(priv, link_info); cvm_oct_note_carrier(priv, link_info);
} }
...@@ -151,9 +143,8 @@ int cvm_oct_common_stop(struct net_device *dev) ...@@ -151,9 +143,8 @@ int cvm_oct_common_stop(struct net_device *dev)
priv->poll = NULL; priv->poll = NULL;
if (priv->phydev) if (dev->phydev)
phy_disconnect(priv->phydev); phy_disconnect(dev->phydev);
priv->phydev = NULL;
if (priv->last_link) { if (priv->last_link) {
link_info.u64 = 0; link_info.u64 = 0;
...@@ -176,6 +167,7 @@ int cvm_oct_phy_setup_device(struct net_device *dev) ...@@ -176,6 +167,7 @@ int cvm_oct_phy_setup_device(struct net_device *dev)
{ {
struct octeon_ethernet *priv = netdev_priv(dev); struct octeon_ethernet *priv = netdev_priv(dev);
struct device_node *phy_node; struct device_node *phy_node;
struct phy_device *phydev = NULL;
if (!priv->of_node) if (!priv->of_node)
goto no_phy; goto no_phy;
...@@ -193,14 +185,14 @@ int cvm_oct_phy_setup_device(struct net_device *dev) ...@@ -193,14 +185,14 @@ int cvm_oct_phy_setup_device(struct net_device *dev)
if (!phy_node) if (!phy_node)
goto no_phy; goto no_phy;
priv->phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0, phydev = of_phy_connect(dev, phy_node, cvm_oct_adjust_link, 0,
PHY_INTERFACE_MODE_GMII); PHY_INTERFACE_MODE_GMII);
if (!priv->phydev) if (!phydev)
return -ENODEV; return -ENODEV;
priv->last_link = 0; priv->last_link = 0;
phy_start_aneg(priv->phydev); phy_start_aneg(phydev);
return 0; return 0;
no_phy: no_phy:
......
...@@ -145,7 +145,7 @@ int cvm_oct_rgmii_open(struct net_device *dev) ...@@ -145,7 +145,7 @@ int cvm_oct_rgmii_open(struct net_device *dev)
if (ret) if (ret)
return ret; return ret;
if (priv->phydev) { if (dev->phydev) {
/* /*
* In phydev mode, we need still periodic polling for the * In phydev mode, we need still periodic polling for the
* preamble error checking, and we also need to call this * preamble error checking, and we also need to call this
......
...@@ -457,10 +457,8 @@ int cvm_oct_common_init(struct net_device *dev) ...@@ -457,10 +457,8 @@ int cvm_oct_common_init(struct net_device *dev)
void cvm_oct_common_uninit(struct net_device *dev) void cvm_oct_common_uninit(struct net_device *dev)
{ {
struct octeon_ethernet *priv = netdev_priv(dev); if (dev->phydev)
phy_disconnect(dev->phydev);
if (priv->phydev)
phy_disconnect(priv->phydev);
} }
int cvm_oct_common_open(struct net_device *dev, int cvm_oct_common_open(struct net_device *dev,
...@@ -484,10 +482,10 @@ int cvm_oct_common_open(struct net_device *dev, ...@@ -484,10 +482,10 @@ int cvm_oct_common_open(struct net_device *dev,
if (octeon_is_simulation()) if (octeon_is_simulation())
return 0; return 0;
if (priv->phydev) { if (dev->phydev) {
int r = phy_read_status(priv->phydev); int r = phy_read_status(dev->phydev);
if (r == 0 && priv->phydev->link == 0) if (r == 0 && dev->phydev->link == 0)
netif_carrier_off(dev); netif_carrier_off(dev);
cvm_oct_adjust_link(dev); cvm_oct_adjust_link(dev);
} else { } else {
......
...@@ -40,7 +40,6 @@ struct octeon_ethernet { ...@@ -40,7 +40,6 @@ struct octeon_ethernet {
struct sk_buff_head tx_free_list[16]; struct sk_buff_head tx_free_list[16];
/* Device statistics */ /* Device statistics */
struct net_device_stats stats; struct net_device_stats stats;
struct phy_device *phydev;
unsigned int last_speed; unsigned int last_speed;
unsigned int last_link; unsigned int last_link;
/* Last negotiated link state */ /* Last negotiated link state */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册