Skip to content

Commit 01dea53

Browse files
Philippe Reynesdavem330
authored andcommitted
net: ethernet: arc: emac: 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 fa01848 commit 01dea53

File tree

2 files changed

+12
-18
lines changed

2 files changed

+12
-18
lines changed

drivers/net/ethernet/arc/emac.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ struct arc_emac_priv {
134134

135135
/* Devices */
136136
struct device *dev;
137-
struct phy_device *phy_dev;
138137
struct mii_bus *bus;
139138
struct arc_emac_mdio_bus_data bus_data;
140139

drivers/net/ethernet/arc/emac_main.c

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ static inline int arc_emac_tx_avail(struct arc_emac_priv *priv)
4747
static void arc_emac_adjust_link(struct net_device *ndev)
4848
{
4949
struct arc_emac_priv *priv = netdev_priv(ndev);
50-
struct phy_device *phy_dev = priv->phy_dev;
50+
struct phy_device *phy_dev = ndev->phydev;
5151
unsigned int reg, state_changed = 0;
5252

5353
if (priv->link != phy_dev->link) {
@@ -92,9 +92,7 @@ static void arc_emac_adjust_link(struct net_device *ndev)
9292
static int arc_emac_get_settings(struct net_device *ndev,
9393
struct ethtool_cmd *cmd)
9494
{
95-
struct arc_emac_priv *priv = netdev_priv(ndev);
96-
97-
return phy_ethtool_gset(priv->phy_dev, cmd);
95+
return phy_ethtool_gset(ndev->phydev, cmd);
9896
}
9997

10098
/**
@@ -111,12 +109,10 @@ static int arc_emac_get_settings(struct net_device *ndev,
111109
static int arc_emac_set_settings(struct net_device *ndev,
112110
struct ethtool_cmd *cmd)
113111
{
114-
struct arc_emac_priv *priv = netdev_priv(ndev);
115-
116112
if (!capable(CAP_NET_ADMIN))
117113
return -EPERM;
118114

119-
return phy_ethtool_sset(priv->phy_dev, cmd);
115+
return phy_ethtool_sset(ndev->phydev, cmd);
120116
}
121117

122118
/**
@@ -403,7 +399,7 @@ static void arc_emac_poll_controller(struct net_device *dev)
403399
static int arc_emac_open(struct net_device *ndev)
404400
{
405401
struct arc_emac_priv *priv = netdev_priv(ndev);
406-
struct phy_device *phy_dev = priv->phy_dev;
402+
struct phy_device *phy_dev = ndev->phydev;
407403
int i;
408404

409405
phy_dev->autoneg = AUTONEG_ENABLE;
@@ -474,7 +470,7 @@ static int arc_emac_open(struct net_device *ndev)
474470
/* Enable EMAC */
475471
arc_reg_or(priv, R_CTRL, EN_MASK);
476472

477-
phy_start_aneg(priv->phy_dev);
473+
phy_start_aneg(ndev->phydev);
478474

479475
netif_start_queue(ndev);
480476

@@ -772,6 +768,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
772768
struct device *dev = ndev->dev.parent;
773769
struct resource res_regs;
774770
struct device_node *phy_node;
771+
struct phy_device *phydev = NULL;
775772
struct arc_emac_priv *priv;
776773
const char *mac_addr;
777774
unsigned int id, clock_frequency, irq;
@@ -887,16 +884,16 @@ int arc_emac_probe(struct net_device *ndev, int interface)
887884
goto out_clken;
888885
}
889886

890-
priv->phy_dev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0,
891-
interface);
892-
if (!priv->phy_dev) {
887+
phydev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0,
888+
interface);
889+
if (!phydev) {
893890
dev_err(dev, "of_phy_connect() failed\n");
894891
err = -ENODEV;
895892
goto out_mdio;
896893
}
897894

898895
dev_info(dev, "connected to %s phy with id 0x%x\n",
899-
priv->phy_dev->drv->name, priv->phy_dev->phy_id);
896+
phydev->drv->name, phydev->phy_id);
900897

901898
netif_napi_add(ndev, &priv->napi, arc_emac_poll, ARC_EMAC_NAPI_WEIGHT);
902899

@@ -910,8 +907,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
910907

911908
out_netif_api:
912909
netif_napi_del(&priv->napi);
913-
phy_disconnect(priv->phy_dev);
914-
priv->phy_dev = NULL;
910+
phy_disconnect(phydev);
915911
out_mdio:
916912
arc_mdio_remove(priv);
917913
out_clken:
@@ -925,8 +921,7 @@ int arc_emac_remove(struct net_device *ndev)
925921
{
926922
struct arc_emac_priv *priv = netdev_priv(ndev);
927923

928-
phy_disconnect(priv->phy_dev);
929-
priv->phy_dev = NULL;
924+
phy_disconnect(ndev->phydev);
930925
arc_mdio_remove(priv);
931926
unregister_netdev(ndev);
932927
netif_napi_del(&priv->napi);

0 commit comments

Comments
 (0)