Skip to content

Commit 2a62416

Browse files
Philippe Reynesdavem330
authored andcommitted
net: ethernet: ixp4xx_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 in the private structure, and update the driver to use the one contained in struct net_device. Signed-off-by: Philippe Reynes <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 2c08740 commit 2a62416

File tree

1 file changed

+16
-20
lines changed

1 file changed

+16
-20
lines changed

drivers/net/ethernet/xscale/ixp4xx_eth.c

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ struct port {
171171
struct npe *npe;
172172
struct net_device *netdev;
173173
struct napi_struct napi;
174-
struct phy_device *phydev;
175174
struct eth_plat_info *plat;
176175
buffer_t *rx_buff_tab[RX_DESCS], *tx_buff_tab[TX_DESCS];
177176
struct desc *desc_tab; /* coherent */
@@ -562,7 +561,7 @@ static void ixp4xx_mdio_remove(void)
562561
static void ixp4xx_adjust_link(struct net_device *dev)
563562
{
564563
struct port *port = netdev_priv(dev);
565-
struct phy_device *phydev = port->phydev;
564+
struct phy_device *phydev = dev->phydev;
566565

567566
if (!phydev->link) {
568567
if (port->speed) {
@@ -976,8 +975,6 @@ static void eth_set_mcast_list(struct net_device *dev)
976975

977976
static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
978977
{
979-
struct port *port = netdev_priv(dev);
980-
981978
if (!netif_running(dev))
982979
return -EINVAL;
983980

@@ -988,7 +985,7 @@ static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
988985
return hwtstamp_get(dev, req);
989986
}
990987

991-
return phy_mii_ioctl(port->phydev, req, cmd);
988+
return phy_mii_ioctl(dev->phydev, req, cmd);
992989
}
993990

994991
/* ethtool support */
@@ -1007,20 +1004,17 @@ static void ixp4xx_get_drvinfo(struct net_device *dev,
10071004

10081005
static int ixp4xx_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
10091006
{
1010-
struct port *port = netdev_priv(dev);
1011-
return phy_ethtool_gset(port->phydev, cmd);
1007+
return phy_ethtool_gset(dev->phydev, cmd);
10121008
}
10131009

10141010
static int ixp4xx_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
10151011
{
1016-
struct port *port = netdev_priv(dev);
1017-
return phy_ethtool_sset(port->phydev, cmd);
1012+
return phy_ethtool_sset(dev->phydev, cmd);
10181013
}
10191014

10201015
static int ixp4xx_nway_reset(struct net_device *dev)
10211016
{
1022-
struct port *port = netdev_priv(dev);
1023-
return phy_start_aneg(port->phydev);
1017+
return phy_start_aneg(dev->phydev);
10241018
}
10251019

10261020
int ixp46x_phc_index = -1;
@@ -1259,7 +1253,7 @@ static int eth_open(struct net_device *dev)
12591253
}
12601254

12611255
port->speed = 0; /* force "link up" message */
1262-
phy_start(port->phydev);
1256+
phy_start(dev->phydev);
12631257

12641258
for (i = 0; i < ETH_ALEN; i++)
12651259
__raw_writel(dev->dev_addr[i], &port->regs->hw_addr[i]);
@@ -1380,7 +1374,7 @@ static int eth_close(struct net_device *dev)
13801374
printk(KERN_CRIT "%s: unable to disable loopback\n",
13811375
dev->name);
13821376

1383-
phy_stop(port->phydev);
1377+
phy_stop(dev->phydev);
13841378

13851379
if (!ports_open)
13861380
qmgr_disable_irq(TXDONE_QUEUE);
@@ -1405,6 +1399,7 @@ static int eth_init_one(struct platform_device *pdev)
14051399
struct port *port;
14061400
struct net_device *dev;
14071401
struct eth_plat_info *plat = dev_get_platdata(&pdev->dev);
1402+
struct phy_device *phydev = NULL;
14081403
u32 regs_phys;
14091404
char phy_id[MII_BUS_ID_SIZE + 3];
14101405
int err;
@@ -1466,14 +1461,14 @@ static int eth_init_one(struct platform_device *pdev)
14661461

14671462
snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
14681463
mdio_bus->id, plat->phy);
1469-
port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
1470-
PHY_INTERFACE_MODE_MII);
1471-
if (IS_ERR(port->phydev)) {
1472-
err = PTR_ERR(port->phydev);
1464+
phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
1465+
PHY_INTERFACE_MODE_MII);
1466+
if (IS_ERR(phydev)) {
1467+
err = PTR_ERR(phydev);
14731468
goto err_free_mem;
14741469
}
14751470

1476-
port->phydev->irq = PHY_POLL;
1471+
phydev->irq = PHY_POLL;
14771472

14781473
if ((err = register_netdev(dev)))
14791474
goto err_phy_dis;
@@ -1484,7 +1479,7 @@ static int eth_init_one(struct platform_device *pdev)
14841479
return 0;
14851480

14861481
err_phy_dis:
1487-
phy_disconnect(port->phydev);
1482+
phy_disconnect(phydev);
14881483
err_free_mem:
14891484
npe_port_tab[NPE_ID(port->id)] = NULL;
14901485
release_resource(port->mem_res);
@@ -1498,10 +1493,11 @@ static int eth_init_one(struct platform_device *pdev)
14981493
static int eth_remove_one(struct platform_device *pdev)
14991494
{
15001495
struct net_device *dev = platform_get_drvdata(pdev);
1496+
struct phy_device *phydev = dev->phydev;
15011497
struct port *port = netdev_priv(dev);
15021498

15031499
unregister_netdev(dev);
1504-
phy_disconnect(port->phydev);
1500+
phy_disconnect(phydev);
15051501
npe_port_tab[NPE_ID(port->id)] = NULL;
15061502
npe_release(port->npe);
15071503
release_resource(port->mem_res);

0 commit comments

Comments
 (0)