Skip to content

Commit 0f63517

Browse files
Philippe Reynesdavem330
authored andcommitted
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: Philippe Reynes <tremyfr@gmail.com> Acked-by: Sergei Shtylyov <sergei.shtylyov@cogentembedded.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent f290040 commit 0f63517

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

drivers/net/ethernet/renesas/ravb.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1011,7 +1011,6 @@ struct ravb_private {
10111011
struct work_struct work;
10121012
/* MII transceiver section. */
10131013
struct mii_bus *mii_bus; /* MDIO bus control */
1014-
struct phy_device *phydev; /* PHY device control */
10151014
int link;
10161015
phy_interface_t phy_interface;
10171016
int msg_enable;

drivers/net/ethernet/renesas/ravb_main.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -942,7 +942,7 @@ static int ravb_poll(struct napi_struct *napi, int budget)
942942
static void ravb_adjust_link(struct net_device *ndev)
943943
{
944944
struct ravb_private *priv = netdev_priv(ndev);
945-
struct phy_device *phydev = priv->phydev;
945+
struct phy_device *phydev = ndev->phydev;
946946
bool new_state = false;
947947

948948
if (phydev->link) {
@@ -1032,22 +1032,19 @@ static int ravb_phy_init(struct net_device *ndev)
10321032

10331033
phy_attached_info(phydev);
10341034

1035-
priv->phydev = phydev;
1036-
10371035
return 0;
10381036
}
10391037

10401038
/* PHY control start function */
10411039
static int ravb_phy_start(struct net_device *ndev)
10421040
{
1043-
struct ravb_private *priv = netdev_priv(ndev);
10441041
int error;
10451042

10461043
error = ravb_phy_init(ndev);
10471044
if (error)
10481045
return error;
10491046

1050-
phy_start(priv->phydev);
1047+
phy_start(ndev->phydev);
10511048

10521049
return 0;
10531050
}
@@ -1058,9 +1055,9 @@ static int ravb_get_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
10581055
int error = -ENODEV;
10591056
unsigned long flags;
10601057

1061-
if (priv->phydev) {
1058+
if (ndev->phydev) {
10621059
spin_lock_irqsave(&priv->lock, flags);
1063-
error = phy_ethtool_gset(priv->phydev, ecmd);
1060+
error = phy_ethtool_gset(ndev->phydev, ecmd);
10641061
spin_unlock_irqrestore(&priv->lock, flags);
10651062
}
10661063

@@ -1073,15 +1070,15 @@ static int ravb_set_settings(struct net_device *ndev, struct ethtool_cmd *ecmd)
10731070
unsigned long flags;
10741071
int error;
10751072

1076-
if (!priv->phydev)
1073+
if (!ndev->phydev)
10771074
return -ENODEV;
10781075

10791076
spin_lock_irqsave(&priv->lock, flags);
10801077

10811078
/* Disable TX and RX */
10821079
ravb_rcv_snd_disable(ndev);
10831080

1084-
error = phy_ethtool_sset(priv->phydev, ecmd);
1081+
error = phy_ethtool_sset(ndev->phydev, ecmd);
10851082
if (error)
10861083
goto error_exit;
10871084

@@ -1110,9 +1107,9 @@ static int ravb_nway_reset(struct net_device *ndev)
11101107
int error = -ENODEV;
11111108
unsigned long flags;
11121109

1113-
if (priv->phydev) {
1110+
if (ndev->phydev) {
11141111
spin_lock_irqsave(&priv->lock, flags);
1115-
error = phy_start_aneg(priv->phydev);
1112+
error = phy_start_aneg(ndev->phydev);
11161113
spin_unlock_irqrestore(&priv->lock, flags);
11171114
}
11181115

@@ -1661,10 +1658,9 @@ static int ravb_close(struct net_device *ndev)
16611658
}
16621659

16631660
/* PHY disconnect */
1664-
if (priv->phydev) {
1665-
phy_stop(priv->phydev);
1666-
phy_disconnect(priv->phydev);
1667-
priv->phydev = NULL;
1661+
if (ndev->phydev) {
1662+
phy_stop(ndev->phydev);
1663+
phy_disconnect(ndev->phydev);
16681664
}
16691665

16701666
if (priv->chip_id != RCAR_GEN2) {
@@ -1753,8 +1749,7 @@ static int ravb_hwtstamp_set(struct net_device *ndev, struct ifreq *req)
17531749
/* ioctl to device function */
17541750
static int ravb_do_ioctl(struct net_device *ndev, struct ifreq *req, int cmd)
17551751
{
1756-
struct ravb_private *priv = netdev_priv(ndev);
1757-
struct phy_device *phydev = priv->phydev;
1752+
struct phy_device *phydev = ndev->phydev;
17581753

17591754
if (!netif_running(ndev))
17601755
return -EINVAL;

0 commit comments

Comments
 (0)