Commit b1b7dcff authored by Philippe Reynes's avatar Philippe Reynes Committed by David S. Miller

net: ethernet: xilinx: axienet: 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
phy in the private structure, and update the driver to use the
one contained in struct net_device.
Signed-off-by: default avatarPhilippe Reynes <tremyfr@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 3a11d9ef
...@@ -382,7 +382,6 @@ struct axidma_bd { ...@@ -382,7 +382,6 @@ struct axidma_bd {
* struct axienet_local - axienet private per device data * struct axienet_local - axienet private per device data
* @ndev: Pointer for net_device to which it will be attached. * @ndev: Pointer for net_device to which it will be attached.
* @dev: Pointer to device structure * @dev: Pointer to device structure
* @phy_dev: Pointer to PHY device structure attached to the axienet_local
* @phy_node: Pointer to device node structure * @phy_node: Pointer to device node structure
* @mii_bus: Pointer to MII bus structure * @mii_bus: Pointer to MII bus structure
* @regs: Base address for the axienet_local device address space * @regs: Base address for the axienet_local device address space
...@@ -420,7 +419,6 @@ struct axienet_local { ...@@ -420,7 +419,6 @@ struct axienet_local {
struct device *dev; struct device *dev;
/* Connection to PHY device */ /* Connection to PHY device */
struct phy_device *phy_dev; /* Pointer to PHY device */
struct device_node *phy_node; struct device_node *phy_node;
/* MDIO bus data */ /* MDIO bus data */
......
...@@ -525,7 +525,7 @@ static void axienet_adjust_link(struct net_device *ndev) ...@@ -525,7 +525,7 @@ static void axienet_adjust_link(struct net_device *ndev)
u32 link_state; u32 link_state;
u32 setspeed = 1; u32 setspeed = 1;
struct axienet_local *lp = netdev_priv(ndev); struct axienet_local *lp = netdev_priv(ndev);
struct phy_device *phy = lp->phy_dev; struct phy_device *phy = ndev->phydev;
link_state = phy->speed | (phy->duplex << 1) | phy->link; link_state = phy->speed | (phy->duplex << 1) | phy->link;
if (lp->last_link != link_state) { if (lp->last_link != link_state) {
...@@ -911,6 +911,7 @@ static int axienet_open(struct net_device *ndev) ...@@ -911,6 +911,7 @@ static int axienet_open(struct net_device *ndev)
{ {
int ret, mdio_mcreg; int ret, mdio_mcreg;
struct axienet_local *lp = netdev_priv(ndev); struct axienet_local *lp = netdev_priv(ndev);
struct phy_device *phydev = NULL;
dev_dbg(&ndev->dev, "axienet_open()\n"); dev_dbg(&ndev->dev, "axienet_open()\n");
...@@ -934,19 +935,19 @@ static int axienet_open(struct net_device *ndev) ...@@ -934,19 +935,19 @@ static int axienet_open(struct net_device *ndev)
if (lp->phy_node) { if (lp->phy_node) {
if (lp->phy_type == XAE_PHY_TYPE_GMII) { if (lp->phy_type == XAE_PHY_TYPE_GMII) {
lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node, phydev = of_phy_connect(lp->ndev, lp->phy_node,
axienet_adjust_link, 0, axienet_adjust_link, 0,
PHY_INTERFACE_MODE_GMII); PHY_INTERFACE_MODE_GMII);
} else if (lp->phy_type == XAE_PHY_TYPE_RGMII_2_0) { } else if (lp->phy_type == XAE_PHY_TYPE_RGMII_2_0) {
lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node, phydev = of_phy_connect(lp->ndev, lp->phy_node,
axienet_adjust_link, 0, axienet_adjust_link, 0,
PHY_INTERFACE_MODE_RGMII_ID); PHY_INTERFACE_MODE_RGMII_ID);
} }
if (!lp->phy_dev) if (!phydev)
dev_err(lp->dev, "of_phy_connect() failed\n"); dev_err(lp->dev, "of_phy_connect() failed\n");
else else
phy_start(lp->phy_dev); phy_start(phydev);
} }
/* Enable tasklets for Axi DMA error handling */ /* Enable tasklets for Axi DMA error handling */
...@@ -967,9 +968,8 @@ static int axienet_open(struct net_device *ndev) ...@@ -967,9 +968,8 @@ static int axienet_open(struct net_device *ndev)
err_rx_irq: err_rx_irq:
free_irq(lp->tx_irq, ndev); free_irq(lp->tx_irq, ndev);
err_tx_irq: err_tx_irq:
if (lp->phy_dev) if (phydev)
phy_disconnect(lp->phy_dev); phy_disconnect(phydev);
lp->phy_dev = NULL;
tasklet_kill(&lp->dma_err_tasklet); tasklet_kill(&lp->dma_err_tasklet);
dev_err(lp->dev, "request_irq() failed\n"); dev_err(lp->dev, "request_irq() failed\n");
return ret; return ret;
...@@ -1006,9 +1006,8 @@ static int axienet_stop(struct net_device *ndev) ...@@ -1006,9 +1006,8 @@ static int axienet_stop(struct net_device *ndev)
free_irq(lp->tx_irq, ndev); free_irq(lp->tx_irq, ndev);
free_irq(lp->rx_irq, ndev); free_irq(lp->rx_irq, ndev);
if (lp->phy_dev) if (ndev->phydev)
phy_disconnect(lp->phy_dev); phy_disconnect(ndev->phydev);
lp->phy_dev = NULL;
axienet_dma_bd_release(ndev); axienet_dma_bd_release(ndev);
return 0; return 0;
...@@ -1092,8 +1091,7 @@ static const struct net_device_ops axienet_netdev_ops = { ...@@ -1092,8 +1091,7 @@ static const struct net_device_ops axienet_netdev_ops = {
static int axienet_ethtools_get_settings(struct net_device *ndev, static int axienet_ethtools_get_settings(struct net_device *ndev,
struct ethtool_cmd *ecmd) struct ethtool_cmd *ecmd)
{ {
struct axienet_local *lp = netdev_priv(ndev); struct phy_device *phydev = ndev->phydev;
struct phy_device *phydev = lp->phy_dev;
if (!phydev) if (!phydev)
return -ENODEV; return -ENODEV;
return phy_ethtool_gset(phydev, ecmd); return phy_ethtool_gset(phydev, ecmd);
...@@ -1115,8 +1113,7 @@ static int axienet_ethtools_get_settings(struct net_device *ndev, ...@@ -1115,8 +1113,7 @@ static int axienet_ethtools_get_settings(struct net_device *ndev,
static int axienet_ethtools_set_settings(struct net_device *ndev, static int axienet_ethtools_set_settings(struct net_device *ndev,
struct ethtool_cmd *ecmd) struct ethtool_cmd *ecmd)
{ {
struct axienet_local *lp = netdev_priv(ndev); struct phy_device *phydev = ndev->phydev;
struct phy_device *phydev = lp->phy_dev;
if (!phydev) if (!phydev)
return -ENODEV; return -ENODEV;
return phy_ethtool_sset(phydev, ecmd); return phy_ethtool_sset(phydev, ecmd);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment