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

net: ethernet: renesas: sh_eth: 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_dev 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>
Tested-by: default avatarSimon Horman <horms+renesas@verge.net.au>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 05b8ad25
...@@ -1723,7 +1723,7 @@ static int sh_eth_poll(struct napi_struct *napi, int budget) ...@@ -1723,7 +1723,7 @@ static int sh_eth_poll(struct napi_struct *napi, int budget)
static void sh_eth_adjust_link(struct net_device *ndev) static void sh_eth_adjust_link(struct net_device *ndev)
{ {
struct sh_eth_private *mdp = netdev_priv(ndev); struct sh_eth_private *mdp = netdev_priv(ndev);
struct phy_device *phydev = mdp->phydev; struct phy_device *phydev = ndev->phydev;
int new_state = 0; int new_state = 0;
if (phydev->link) { if (phydev->link) {
...@@ -1800,22 +1800,19 @@ static int sh_eth_phy_init(struct net_device *ndev) ...@@ -1800,22 +1800,19 @@ static int sh_eth_phy_init(struct net_device *ndev)
phy_attached_info(phydev); phy_attached_info(phydev);
mdp->phydev = phydev;
return 0; return 0;
} }
/* PHY control start function */ /* PHY control start function */
static int sh_eth_phy_start(struct net_device *ndev) static int sh_eth_phy_start(struct net_device *ndev)
{ {
struct sh_eth_private *mdp = netdev_priv(ndev);
int ret; int ret;
ret = sh_eth_phy_init(ndev); ret = sh_eth_phy_init(ndev);
if (ret) if (ret)
return ret; return ret;
phy_start(mdp->phydev); phy_start(ndev->phydev);
return 0; return 0;
} }
...@@ -1827,11 +1824,11 @@ static int sh_eth_get_settings(struct net_device *ndev, ...@@ -1827,11 +1824,11 @@ static int sh_eth_get_settings(struct net_device *ndev,
unsigned long flags; unsigned long flags;
int ret; int ret;
if (!mdp->phydev) if (!ndev->phydev)
return -ENODEV; return -ENODEV;
spin_lock_irqsave(&mdp->lock, flags); spin_lock_irqsave(&mdp->lock, flags);
ret = phy_ethtool_gset(mdp->phydev, ecmd); ret = phy_ethtool_gset(ndev->phydev, ecmd);
spin_unlock_irqrestore(&mdp->lock, flags); spin_unlock_irqrestore(&mdp->lock, flags);
return ret; return ret;
...@@ -1844,7 +1841,7 @@ static int sh_eth_set_settings(struct net_device *ndev, ...@@ -1844,7 +1841,7 @@ static int sh_eth_set_settings(struct net_device *ndev,
unsigned long flags; unsigned long flags;
int ret; int ret;
if (!mdp->phydev) if (!ndev->phydev)
return -ENODEV; return -ENODEV;
spin_lock_irqsave(&mdp->lock, flags); spin_lock_irqsave(&mdp->lock, flags);
...@@ -1852,7 +1849,7 @@ static int sh_eth_set_settings(struct net_device *ndev, ...@@ -1852,7 +1849,7 @@ static int sh_eth_set_settings(struct net_device *ndev,
/* disable tx and rx */ /* disable tx and rx */
sh_eth_rcv_snd_disable(ndev); sh_eth_rcv_snd_disable(ndev);
ret = phy_ethtool_sset(mdp->phydev, ecmd); ret = phy_ethtool_sset(ndev->phydev, ecmd);
if (ret) if (ret)
goto error_exit; goto error_exit;
...@@ -2067,11 +2064,11 @@ static int sh_eth_nway_reset(struct net_device *ndev) ...@@ -2067,11 +2064,11 @@ static int sh_eth_nway_reset(struct net_device *ndev)
unsigned long flags; unsigned long flags;
int ret; int ret;
if (!mdp->phydev) if (!ndev->phydev)
return -ENODEV; return -ENODEV;
spin_lock_irqsave(&mdp->lock, flags); spin_lock_irqsave(&mdp->lock, flags);
ret = phy_start_aneg(mdp->phydev); ret = phy_start_aneg(ndev->phydev);
spin_unlock_irqrestore(&mdp->lock, flags); spin_unlock_irqrestore(&mdp->lock, flags);
return ret; return ret;
...@@ -2408,10 +2405,9 @@ static int sh_eth_close(struct net_device *ndev) ...@@ -2408,10 +2405,9 @@ static int sh_eth_close(struct net_device *ndev)
sh_eth_dev_exit(ndev); sh_eth_dev_exit(ndev);
/* PHY Disconnect */ /* PHY Disconnect */
if (mdp->phydev) { if (ndev->phydev) {
phy_stop(mdp->phydev); phy_stop(ndev->phydev);
phy_disconnect(mdp->phydev); phy_disconnect(ndev->phydev);
mdp->phydev = NULL;
} }
free_irq(ndev->irq, ndev); free_irq(ndev->irq, ndev);
...@@ -2429,8 +2425,7 @@ static int sh_eth_close(struct net_device *ndev) ...@@ -2429,8 +2425,7 @@ static int sh_eth_close(struct net_device *ndev)
/* ioctl to device function */ /* ioctl to device function */
static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd) static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
{ {
struct sh_eth_private *mdp = netdev_priv(ndev); struct phy_device *phydev = ndev->phydev;
struct phy_device *phydev = mdp->phydev;
if (!netif_running(ndev)) if (!netif_running(ndev))
return -EINVAL; return -EINVAL;
......
...@@ -518,7 +518,6 @@ struct sh_eth_private { ...@@ -518,7 +518,6 @@ struct sh_eth_private {
/* MII transceiver section. */ /* MII transceiver section. */
u32 phy_id; /* PHY ID */ u32 phy_id; /* PHY ID */
struct mii_bus *mii_bus; /* MDIO bus control */ struct mii_bus *mii_bus; /* MDIO bus control */
struct phy_device *phydev; /* PHY device control */
int link; int link;
phy_interface_t phy_interface; phy_interface_t phy_interface;
int msg_enable; int msg_enable;
......
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