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

net: ethernet: renesas: ravb: 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>
Acked-by: default avatarSergei Shtylyov <sergei.shtylyov@cogentembedded.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent f290040d
...@@ -1011,7 +1011,6 @@ struct ravb_private { ...@@ -1011,7 +1011,6 @@ struct ravb_private {
struct work_struct work; struct work_struct work;
/* MII transceiver section. */ /* MII transceiver section. */
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;
......
...@@ -942,7 +942,7 @@ static int ravb_poll(struct napi_struct *napi, int budget) ...@@ -942,7 +942,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
static void ravb_adjust_link(struct net_device *ndev) static void ravb_adjust_link(struct net_device *ndev)
{ {
struct ravb_private *priv = netdev_priv(ndev); struct ravb_private *priv = netdev_priv(ndev);
struct phy_device *phydev = priv->phydev; struct phy_device *phydev = ndev->phydev;
bool new_state = false; bool new_state = false;
if (phydev->link) { if (phydev->link) {
...@@ -1032,22 +1032,19 @@ static int ravb_phy_init(struct net_device *ndev) ...@@ -1032,22 +1032,19 @@ static int ravb_phy_init(struct net_device *ndev)
phy_attached_info(phydev); phy_attached_info(phydev);
priv->phydev = phydev;
return 0; return 0;
} }
/* PHY control start function */ /* PHY control start function */
static int ravb_phy_start(struct net_device *ndev) static int ravb_phy_start(struct net_device *ndev)
{ {
struct ravb_private *priv = netdev_priv(ndev);
int error; int error;
error = ravb_phy_init(ndev); error = ravb_phy_init(ndev);
if (error) if (error)
return error; return error;
phy_start(priv->phydev); phy_start(ndev->phydev);
return 0; return 0;
} }
...@@ -1058,9 +1055,9 @@ static int ravb_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) ...@@ -1058,9 +1055,9 @@ static int ravb_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
int error = -ENODEV; int error = -ENODEV;
unsigned long flags; unsigned long flags;
if (priv->phydev) { if (ndev->phydev) {
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
error = phy_ethtool_gset(priv->phydev, ecmd); error = phy_ethtool_gset(ndev->phydev, ecmd);
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
} }
...@@ -1073,7 +1070,7 @@ static int ravb_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) ...@@ -1073,7 +1070,7 @@ static int ravb_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
unsigned long flags; unsigned long flags;
int error; int error;
if (!priv->phydev) if (!ndev->phydev)
return -ENODEV; return -ENODEV;
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
...@@ -1081,7 +1078,7 @@ static int ravb_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd) ...@@ -1081,7 +1078,7 @@ static int ravb_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
/* Disable TX and RX */ /* Disable TX and RX */
ravb_rcv_snd_disable(ndev); ravb_rcv_snd_disable(ndev);
error = phy_ethtool_sset(priv->phydev, ecmd); error = phy_ethtool_sset(ndev->phydev, ecmd);
if (error) if (error)
goto error_exit; goto error_exit;
...@@ -1110,9 +1107,9 @@ static int ravb_nway_reset(struct net_device *ndev) ...@@ -1110,9 +1107,9 @@ static int ravb_nway_reset(struct net_device *ndev)
int error = -ENODEV; int error = -ENODEV;
unsigned long flags; unsigned long flags;
if (priv->phydev) { if (ndev->phydev) {
spin_lock_irqsave(&priv->lock, flags); spin_lock_irqsave(&priv->lock, flags);
error = phy_start_aneg(priv->phydev); error = phy_start_aneg(ndev->phydev);
spin_unlock_irqrestore(&priv->lock, flags); spin_unlock_irqrestore(&priv->lock, flags);
} }
...@@ -1661,10 +1658,9 @@ static int ravb_close(struct net_device *ndev) ...@@ -1661,10 +1658,9 @@ static int ravb_close(struct net_device *ndev)
} }
/* PHY disconnect */ /* PHY disconnect */
if (priv->phydev) { if (ndev->phydev) {
phy_stop(priv->phydev); phy_stop(ndev->phydev);
phy_disconnect(priv->phydev); phy_disconnect(ndev->phydev);
priv->phydev = NULL;
} }
if (priv->chip_id != RCAR_GEN2) { if (priv->chip_id != RCAR_GEN2) {
...@@ -1753,8 +1749,7 @@ static int ravb_hwtstamp_set(struct net_device *ndev, struct ifreq *req) ...@@ -1753,8 +1749,7 @@ static int ravb_hwtstamp_set(struct net_device *ndev, struct ifreq *req)
/* ioctl to device function */ /* ioctl to device function */
static int ravb_do_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) static int ravb_do_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
{ {
struct ravb_private *priv = netdev_priv(ndev); struct phy_device *phydev = ndev->phydev;
struct phy_device *phydev = priv->phydev;
if (!netif_running(ndev)) if (!netif_running(ndev))
return -EINVAL; return -EINVAL;
......
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