Skip to content

Commit 9fd0375

Browse files
Philippe Reynesdavem330
authored andcommitted
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: Philippe Reynes <[email protected]> Tested-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 05b8ad2 commit 9fd0375

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

drivers/net/ethernet/renesas/sh_eth.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1723,7 +1723,7 @@ static int sh_eth_poll(struct napi_struct *napi, int budget)
17231723
static void sh_eth_adjust_link(struct net_device *ndev)
17241724
{
17251725
struct sh_eth_private *mdp = netdev_priv(ndev);
1726-
struct phy_device *phydev = mdp->phydev;
1726+
struct phy_device *phydev = ndev->phydev;
17271727
int new_state = 0;
17281728

17291729
if (phydev->link) {
@@ -1800,22 +1800,19 @@ static int sh_eth_phy_init(struct net_device *ndev)
18001800

18011801
phy_attached_info(phydev);
18021802

1803-
mdp->phydev = phydev;
1804-
18051803
return 0;
18061804
}
18071805

18081806
/* PHY control start function */
18091807
static int sh_eth_phy_start(struct net_device *ndev)
18101808
{
1811-
struct sh_eth_private *mdp = netdev_priv(ndev);
18121809
int ret;
18131810

18141811
ret = sh_eth_phy_init(ndev);
18151812
if (ret)
18161813
return ret;
18171814

1818-
phy_start(mdp->phydev);
1815+
phy_start(ndev->phydev);
18191816

18201817
return 0;
18211818
}
@@ -1827,11 +1824,11 @@ static int sh_eth_get_settings(struct net_device *ndev,
18271824
unsigned long flags;
18281825
int ret;
18291826

1830-
if (!mdp->phydev)
1827+
if (!ndev->phydev)
18311828
return -ENODEV;
18321829

18331830
spin_lock_irqsave(&mdp->lock, flags);
1834-
ret = phy_ethtool_gset(mdp->phydev, ecmd);
1831+
ret = phy_ethtool_gset(ndev->phydev, ecmd);
18351832
spin_unlock_irqrestore(&mdp->lock, flags);
18361833

18371834
return ret;
@@ -1844,15 +1841,15 @@ static int sh_eth_set_settings(struct net_device *ndev,
18441841
unsigned long flags;
18451842
int ret;
18461843

1847-
if (!mdp->phydev)
1844+
if (!ndev->phydev)
18481845
return -ENODEV;
18491846

18501847
spin_lock_irqsave(&mdp->lock, flags);
18511848

18521849
/* disable tx and rx */
18531850
sh_eth_rcv_snd_disable(ndev);
18541851

1855-
ret = phy_ethtool_sset(mdp->phydev, ecmd);
1852+
ret = phy_ethtool_sset(ndev->phydev, ecmd);
18561853
if (ret)
18571854
goto error_exit;
18581855

@@ -2067,11 +2064,11 @@ static int sh_eth_nway_reset(struct net_device *ndev)
20672064
unsigned long flags;
20682065
int ret;
20692066

2070-
if (!mdp->phydev)
2067+
if (!ndev->phydev)
20712068
return -ENODEV;
20722069

20732070
spin_lock_irqsave(&mdp->lock, flags);
2074-
ret = phy_start_aneg(mdp->phydev);
2071+
ret = phy_start_aneg(ndev->phydev);
20752072
spin_unlock_irqrestore(&mdp->lock, flags);
20762073

20772074
return ret;
@@ -2408,10 +2405,9 @@ static int sh_eth_close(struct net_device *ndev)
24082405
sh_eth_dev_exit(ndev);
24092406

24102407
/* PHY Disconnect */
2411-
if (mdp->phydev) {
2412-
phy_stop(mdp->phydev);
2413-
phy_disconnect(mdp->phydev);
2414-
mdp->phydev = NULL;
2408+
if (ndev->phydev) {
2409+
phy_stop(ndev->phydev);
2410+
phy_disconnect(ndev->phydev);
24152411
}
24162412

24172413
free_irq(ndev->irq, ndev);
@@ -2429,8 +2425,7 @@ static int sh_eth_close(struct net_device *ndev)
24292425
/* ioctl to device function */
24302426
static int sh_eth_do_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
24312427
{
2432-
struct sh_eth_private *mdp = netdev_priv(ndev);
2433-
struct phy_device *phydev = mdp->phydev;
2428+
struct phy_device *phydev = ndev->phydev;
24342429

24352430
if (!netif_running(ndev))
24362431
return -EINVAL;

drivers/net/ethernet/renesas/sh_eth.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,6 @@ struct sh_eth_private {
518518
/* MII transceiver section. */
519519
u32 phy_id; /* PHY ID */
520520
struct mii_bus *mii_bus; /* MDIO bus control */
521-
struct phy_device *phydev; /* PHY device control */
522521
int link;
523522
phy_interface_t phy_interface;
524523
int msg_enable;

0 commit comments

Comments
 (0)