1 From b21fcb259313bcf7d4f73ecd5e44948995c8957c Mon Sep 17 00:00:00 2001
2 From: Philippe Reynes <tremyfr@gmail.com>
3 Date: Sun, 19 Jun 2016 22:37:05 +0200
4 Subject: [PATCH 1/2] net: ethernet: bgmac: use phydev from struct net_device
6 The private structure contain a pointer to phydev, but the structure
7 net_device already contain such pointer. So we can remove the pointer
8 phydev in the private structure, and update the driver to use the
9 one contained in struct net_device.
11 Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
14 drivers/net/ethernet/broadcom/bgmac.c | 17 ++++++-----------
15 drivers/net/ethernet/broadcom/bgmac.h | 1 -
16 2 files changed, 6 insertions(+), 12 deletions(-)
18 --- a/drivers/net/ethernet/broadcom/bgmac.c
19 +++ b/drivers/net/ethernet/broadcom/bgmac.c
20 @@ -1324,7 +1324,7 @@ static int bgmac_open(struct net_device
22 napi_enable(&bgmac->napi);
24 - phy_start(bgmac->phy_dev);
25 + phy_start(net_dev->phydev);
27 netif_start_queue(net_dev);
29 @@ -1337,7 +1337,7 @@ static int bgmac_stop(struct net_device
31 netif_carrier_off(net_dev);
33 - phy_stop(bgmac->phy_dev);
34 + phy_stop(net_dev->phydev);
36 napi_disable(&bgmac->napi);
37 bgmac_chip_intrs_off(bgmac);
38 @@ -1375,12 +1375,10 @@ static int bgmac_set_mac_address(struct
40 static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
42 - struct bgmac *bgmac = netdev_priv(net_dev);
44 if (!netif_running(net_dev))
47 - return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
48 + return phy_mii_ioctl(net_dev->phydev, ifr, cmd);
51 static const struct net_device_ops bgmac_netdev_ops = {
52 @@ -1523,7 +1521,7 @@ static int bgmac_get_settings(struct net
54 struct bgmac *bgmac = netdev_priv(net_dev);
56 - return phy_ethtool_gset(bgmac->phy_dev, cmd);
57 + return phy_ethtool_gset(net_dev->phydev, cmd);
60 static int bgmac_set_settings(struct net_device *net_dev,
61 @@ -1531,7 +1529,7 @@ static int bgmac_set_settings(struct net
63 struct bgmac *bgmac = netdev_priv(net_dev);
65 - return phy_ethtool_sset(bgmac->phy_dev, cmd);
66 + return phy_ethtool_sset(net_dev->phydev, cmd);
69 static void bgmac_get_drvinfo(struct net_device *net_dev,
70 @@ -1568,7 +1566,7 @@ static int bgmac_mii_write(struct mii_bu
71 static void bgmac_adjust_link(struct net_device *net_dev)
73 struct bgmac *bgmac = netdev_priv(net_dev);
74 - struct phy_device *phy_dev = bgmac->phy_dev;
75 + struct phy_device *phy_dev = net_dev->phydev;
79 @@ -1612,8 +1610,6 @@ static int bgmac_fixed_phy_register(stru
83 - bgmac->phy_dev = phy_dev;
88 @@ -1666,7 +1662,6 @@ static int bgmac_mii_register(struct bgm
89 err = PTR_ERR(phy_dev);
90 goto err_unregister_bus;
92 - bgmac->phy_dev = phy_dev;
96 --- a/drivers/net/ethernet/broadcom/bgmac.h
97 +++ b/drivers/net/ethernet/broadcom/bgmac.h
98 @@ -441,7 +441,6 @@ struct bgmac {
99 struct net_device *net_dev;
100 struct napi_struct napi;
101 struct mii_bus *mii_bus;
102 - struct phy_device *phy_dev;
105 struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];