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

net: stmmac: 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: default avatarPhilippe Reynes <tremyfr@gmail.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent a54e1612
...@@ -367,8 +367,8 @@ static int socfpga_dwmac_resume(struct device *dev) ...@@ -367,8 +367,8 @@ static int socfpga_dwmac_resume(struct device *dev)
* control register 0, and can be modified by the phy driver * control register 0, and can be modified by the phy driver
* framework. * framework.
*/ */
if (priv->phydev) if (ndev->phydev)
phy_resume(priv->phydev); phy_resume(ndev->phydev);
return stmmac_resume(dev); return stmmac_resume(dev);
} }
......
...@@ -90,7 +90,6 @@ struct stmmac_priv { ...@@ -90,7 +90,6 @@ struct stmmac_priv {
struct mac_device_info *hw; struct mac_device_info *hw;
spinlock_t lock; spinlock_t lock;
struct phy_device *phydev ____cacheline_aligned_in_smp;
int oldlink; int oldlink;
int speed; int speed;
int oldduplex; int oldduplex;
......
...@@ -273,7 +273,7 @@ static int stmmac_ethtool_getsettings(struct net_device *dev, ...@@ -273,7 +273,7 @@ static int stmmac_ethtool_getsettings(struct net_device *dev,
struct ethtool_cmd *cmd) struct ethtool_cmd *cmd)
{ {
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
struct phy_device *phy = priv->phydev; struct phy_device *phy = dev->phydev;
int rc; int rc;
if (priv->hw->pcs & STMMAC_PCS_RGMII || if (priv->hw->pcs & STMMAC_PCS_RGMII ||
...@@ -359,7 +359,7 @@ static int stmmac_ethtool_setsettings(struct net_device *dev, ...@@ -359,7 +359,7 @@ static int stmmac_ethtool_setsettings(struct net_device *dev,
struct ethtool_cmd *cmd) struct ethtool_cmd *cmd)
{ {
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
struct phy_device *phy = priv->phydev; struct phy_device *phy = dev->phydev;
int rc; int rc;
if (priv->hw->pcs & STMMAC_PCS_RGMII || if (priv->hw->pcs & STMMAC_PCS_RGMII ||
...@@ -468,12 +468,12 @@ stmmac_get_pauseparam(struct net_device *netdev, ...@@ -468,12 +468,12 @@ stmmac_get_pauseparam(struct net_device *netdev,
if (!adv_lp.pause) if (!adv_lp.pause)
return; return;
} else { } else {
if (!(priv->phydev->supported & SUPPORTED_Pause) || if (!(netdev->phydev->supported & SUPPORTED_Pause) ||
!(priv->phydev->supported & SUPPORTED_Asym_Pause)) !(netdev->phydev->supported & SUPPORTED_Asym_Pause))
return; return;
} }
pause->autoneg = priv->phydev->autoneg; pause->autoneg = netdev->phydev->autoneg;
if (priv->flow_ctrl & FLOW_RX) if (priv->flow_ctrl & FLOW_RX)
pause->rx_pause = 1; pause->rx_pause = 1;
...@@ -487,7 +487,7 @@ stmmac_set_pauseparam(struct net_device *netdev, ...@@ -487,7 +487,7 @@ stmmac_set_pauseparam(struct net_device *netdev,
struct ethtool_pauseparam *pause) struct ethtool_pauseparam *pause)
{ {
struct stmmac_priv *priv = netdev_priv(netdev); struct stmmac_priv *priv = netdev_priv(netdev);
struct phy_device *phy = priv->phydev; struct phy_device *phy = netdev->phydev;
int new_pause = FLOW_OFF; int new_pause = FLOW_OFF;
if (priv->hw->pcs && priv->hw->mac->pcs_get_adv_lp) { if (priv->hw->pcs && priv->hw->mac->pcs_get_adv_lp) {
...@@ -547,7 +547,7 @@ static void stmmac_get_ethtool_stats(struct net_device *dev, ...@@ -547,7 +547,7 @@ static void stmmac_get_ethtool_stats(struct net_device *dev,
} }
} }
if (priv->eee_enabled) { if (priv->eee_enabled) {
int val = phy_get_eee_err(priv->phydev); int val = phy_get_eee_err(dev->phydev);
if (val) if (val)
priv->xstats.phy_eee_wakeup_error_n = val; priv->xstats.phy_eee_wakeup_error_n = val;
} }
...@@ -666,7 +666,7 @@ static int stmmac_ethtool_op_get_eee(struct net_device *dev, ...@@ -666,7 +666,7 @@ static int stmmac_ethtool_op_get_eee(struct net_device *dev,
edata->eee_active = priv->eee_active; edata->eee_active = priv->eee_active;
edata->tx_lpi_timer = priv->tx_lpi_timer; edata->tx_lpi_timer = priv->tx_lpi_timer;
return phy_ethtool_get_eee(priv->phydev, edata); return phy_ethtool_get_eee(dev->phydev, edata);
} }
static int stmmac_ethtool_op_set_eee(struct net_device *dev, static int stmmac_ethtool_op_set_eee(struct net_device *dev,
...@@ -691,7 +691,7 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev, ...@@ -691,7 +691,7 @@ static int stmmac_ethtool_op_set_eee(struct net_device *dev,
priv->tx_lpi_timer = edata->tx_lpi_timer; priv->tx_lpi_timer = edata->tx_lpi_timer;
} }
return phy_ethtool_set_eee(priv->phydev, edata); return phy_ethtool_set_eee(dev->phydev, edata);
} }
static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv) static u32 stmmac_usec2riwt(u32 usec, struct stmmac_priv *priv)
......
...@@ -221,7 +221,8 @@ static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv) ...@@ -221,7 +221,8 @@ static inline u32 stmmac_rx_dirty(struct stmmac_priv *priv)
*/ */
static inline void stmmac_hw_fix_mac_speed(struct stmmac_priv *priv) static inline void stmmac_hw_fix_mac_speed(struct stmmac_priv *priv)
{ {
struct phy_device *phydev = priv->phydev; struct net_device *ndev = priv->dev;
struct phy_device *phydev = ndev->phydev;
if (likely(priv->plat->fix_mac_speed)) if (likely(priv->plat->fix_mac_speed))
priv->plat->fix_mac_speed(priv->plat->bsp_priv, phydev->speed); priv->plat->fix_mac_speed(priv->plat->bsp_priv, phydev->speed);
...@@ -279,6 +280,7 @@ static void stmmac_eee_ctrl_timer(unsigned long arg) ...@@ -279,6 +280,7 @@ static void stmmac_eee_ctrl_timer(unsigned long arg)
*/ */
bool stmmac_eee_init(struct stmmac_priv *priv) bool stmmac_eee_init(struct stmmac_priv *priv)
{ {
struct net_device *ndev = priv->dev;
unsigned long flags; unsigned long flags;
bool ret = false; bool ret = false;
...@@ -295,7 +297,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) ...@@ -295,7 +297,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
int tx_lpi_timer = priv->tx_lpi_timer; int tx_lpi_timer = priv->tx_lpi_timer;
/* Check if the PHY supports EEE */ /* Check if the PHY supports EEE */
if (phy_init_eee(priv->phydev, 1)) { if (phy_init_eee(ndev->phydev, 1)) {
/* To manage at run-time if the EEE cannot be supported /* To manage at run-time if the EEE cannot be supported
* anymore (for example because the lp caps have been * anymore (for example because the lp caps have been
* changed). * changed).
...@@ -327,7 +329,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv) ...@@ -327,7 +329,7 @@ bool stmmac_eee_init(struct stmmac_priv *priv)
tx_lpi_timer); tx_lpi_timer);
} }
/* Set HW EEE according to the speed */ /* Set HW EEE according to the speed */
priv->hw->mac->set_eee_pls(priv->hw, priv->phydev->link); priv->hw->mac->set_eee_pls(priv->hw, ndev->phydev->link);
ret = true; ret = true;
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
...@@ -691,7 +693,7 @@ static void stmmac_release_ptp(struct stmmac_priv *priv) ...@@ -691,7 +693,7 @@ static void stmmac_release_ptp(struct stmmac_priv *priv)
static void stmmac_adjust_link(struct net_device *dev) static void stmmac_adjust_link(struct net_device *dev)
{ {
struct stmmac_priv *priv = netdev_priv(dev); struct stmmac_priv *priv = netdev_priv(dev);
struct phy_device *phydev = priv->phydev; struct phy_device *phydev = dev->phydev;
unsigned long flags; unsigned long flags;
int new_state = 0; int new_state = 0;
unsigned int fc = priv->flow_ctrl, pause_time = priv->pause; unsigned int fc = priv->flow_ctrl, pause_time = priv->pause;
...@@ -874,8 +876,6 @@ static int stmmac_init_phy(struct net_device *dev) ...@@ -874,8 +876,6 @@ static int stmmac_init_phy(struct net_device *dev)
pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)" pr_debug("stmmac_init_phy: %s: attached to PHY (UID 0x%x)"
" Link = %d\n", dev->name, phydev->phy_id, phydev->link); " Link = %d\n", dev->name, phydev->phy_id, phydev->link);
priv->phydev = phydev;
return 0; return 0;
} }
...@@ -1800,8 +1800,8 @@ static int stmmac_open(struct net_device *dev) ...@@ -1800,8 +1800,8 @@ static int stmmac_open(struct net_device *dev)
stmmac_init_tx_coalesce(priv); stmmac_init_tx_coalesce(priv);
if (priv->phydev) if (dev->phydev)
phy_start(priv->phydev); phy_start(dev->phydev);
/* Request the IRQ lines */ /* Request the IRQ lines */
ret = request_irq(dev->irq, stmmac_interrupt, ret = request_irq(dev->irq, stmmac_interrupt,
...@@ -1848,8 +1848,8 @@ static int stmmac_open(struct net_device *dev) ...@@ -1848,8 +1848,8 @@ static int stmmac_open(struct net_device *dev)
init_error: init_error:
free_dma_desc_resources(priv); free_dma_desc_resources(priv);
dma_desc_error: dma_desc_error:
if (priv->phydev) if (dev->phydev)
phy_disconnect(priv->phydev); phy_disconnect(dev->phydev);
return ret; return ret;
} }
...@@ -1868,10 +1868,9 @@ static int stmmac_release(struct net_device *dev) ...@@ -1868,10 +1868,9 @@ static int stmmac_release(struct net_device *dev)
del_timer_sync(&priv->eee_ctrl_timer); del_timer_sync(&priv->eee_ctrl_timer);
/* Stop and disconnect the PHY */ /* Stop and disconnect the PHY */
if (priv->phydev) { if (dev->phydev) {
phy_stop(priv->phydev); phy_stop(dev->phydev);
phy_disconnect(priv->phydev); phy_disconnect(dev->phydev);
priv->phydev = NULL;
} }
netif_stop_queue(dev); netif_stop_queue(dev);
...@@ -2863,7 +2862,6 @@ static void stmmac_poll_controller(struct net_device *dev) ...@@ -2863,7 +2862,6 @@ static void stmmac_poll_controller(struct net_device *dev)
*/ */
static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ {
struct stmmac_priv *priv = netdev_priv(dev);
int ret = -EOPNOTSUPP; int ret = -EOPNOTSUPP;
if (!netif_running(dev)) if (!netif_running(dev))
...@@ -2873,9 +2871,9 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) ...@@ -2873,9 +2871,9 @@ static int stmmac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
case SIOCGMIIPHY: case SIOCGMIIPHY:
case SIOCGMIIREG: case SIOCGMIIREG:
case SIOCSMIIREG: case SIOCSMIIREG:
if (!priv->phydev) if (!dev->phydev)
return -EINVAL; return -EINVAL;
ret = phy_mii_ioctl(priv->phydev, rq, cmd); ret = phy_mii_ioctl(dev->phydev, rq, cmd);
break; break;
case SIOCSHWTSTAMP: case SIOCSHWTSTAMP:
ret = stmmac_hwtstamp_ioctl(dev, rq); ret = stmmac_hwtstamp_ioctl(dev, rq);
...@@ -3428,8 +3426,8 @@ int stmmac_suspend(struct device *dev) ...@@ -3428,8 +3426,8 @@ int stmmac_suspend(struct device *dev)
if (!ndev || !netif_running(ndev)) if (!ndev || !netif_running(ndev))
return 0; return 0;
if (priv->phydev) if (ndev->phydev)
phy_stop(priv->phydev); phy_stop(ndev->phydev);
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -3523,8 +3521,8 @@ int stmmac_resume(struct device *dev) ...@@ -3523,8 +3521,8 @@ int stmmac_resume(struct device *dev)
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
if (priv->phydev) if (ndev->phydev)
phy_start(priv->phydev); phy_start(ndev->phydev);
return 0; return 0;
} }
......
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