Skip to content

Commit

Permalink
net: ethernet: bgmac: use phydev from struct net_device
Browse files Browse the repository at this point in the history
The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phydev 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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Philippe Reynes authored and David S. Miller committed Jun 22, 2016
1 parent 11bbb17 commit b21fcb2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 12 deletions.
17 changes: 6 additions & 11 deletions drivers/net/ethernet/broadcom/bgmac.c
Original file line number Diff line number Diff line change
Expand Up @@ -1320,7 +1320,7 @@ static int bgmac_open(struct net_device *net_dev)
}
napi_enable(&bgmac->napi);

phy_start(bgmac->phy_dev);
phy_start(net_dev->phydev);

netif_carrier_on(net_dev);
return 0;
Expand All @@ -1332,7 +1332,7 @@ static int bgmac_stop(struct net_device *net_dev)

netif_carrier_off(net_dev);

phy_stop(bgmac->phy_dev);
phy_stop(net_dev->phydev);

napi_disable(&bgmac->napi);
bgmac_chip_intrs_off(bgmac);
Expand Down Expand Up @@ -1370,12 +1370,10 @@ static int bgmac_set_mac_address(struct net_device *net_dev, void *addr)

static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
{
struct bgmac *bgmac = netdev_priv(net_dev);

if (!netif_running(net_dev))
return -EINVAL;

return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
return phy_mii_ioctl(net_dev->phydev, ifr, cmd);
}

static const struct net_device_ops bgmac_netdev_ops = {
Expand Down Expand Up @@ -1518,15 +1516,15 @@ static int bgmac_get_settings(struct net_device *net_dev,
{
struct bgmac *bgmac = netdev_priv(net_dev);

return phy_ethtool_gset(bgmac->phy_dev, cmd);
return phy_ethtool_gset(net_dev->phydev, cmd);
}

static int bgmac_set_settings(struct net_device *net_dev,
struct ethtool_cmd *cmd)
{
struct bgmac *bgmac = netdev_priv(net_dev);

return phy_ethtool_sset(bgmac->phy_dev, cmd);
return phy_ethtool_sset(net_dev->phydev, cmd);
}

static void bgmac_get_drvinfo(struct net_device *net_dev,
Expand Down Expand Up @@ -1563,7 +1561,7 @@ static int bgmac_mii_write(struct mii_bus *bus, int mii_id, int regnum,
static void bgmac_adjust_link(struct net_device *net_dev)
{
struct bgmac *bgmac = netdev_priv(net_dev);
struct phy_device *phy_dev = bgmac->phy_dev;
struct phy_device *phy_dev = net_dev->phydev;
bool update = false;

if (phy_dev->link) {
Expand Down Expand Up @@ -1607,8 +1605,6 @@ static int bgmac_fixed_phy_register(struct bgmac *bgmac)
return err;
}

bgmac->phy_dev = phy_dev;

return err;
}

Expand Down Expand Up @@ -1653,7 +1649,6 @@ static int bgmac_mii_register(struct bgmac *bgmac)
err = PTR_ERR(phy_dev);
goto err_unregister_bus;
}
bgmac->phy_dev = phy_dev;

return err;

Expand Down
1 change: 0 additions & 1 deletion drivers/net/ethernet/broadcom/bgmac.h
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,6 @@ struct bgmac {
struct net_device *net_dev;
struct napi_struct napi;
struct mii_bus *mii_bus;
struct phy_device *phy_dev;

/* DMA */
struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];
Expand Down

0 comments on commit b21fcb2

Please sign in to comment.