8c97b09970515c9c04ce17b54500485f2cf9ad7a
[openwrt/staging/mans0n.git] /
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
5
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.
10
11 Signed-off-by: Philippe Reynes <tremyfr@gmail.com>
12 Signed-off-by: David S. Miller <davem@davemloft.net>
13 ---
14 drivers/net/ethernet/broadcom/bgmac.c | 17 ++++++-----------
15 drivers/net/ethernet/broadcom/bgmac.h | 1 -
16 2 files changed, 6 insertions(+), 12 deletions(-)
17
18 --- a/drivers/net/ethernet/broadcom/bgmac.c
19 +++ b/drivers/net/ethernet/broadcom/bgmac.c
20 @@ -1323,7 +1323,7 @@ static int bgmac_open(struct net_device
21 }
22 napi_enable(&bgmac->napi);
23
24 - phy_start(bgmac->phy_dev);
25 + phy_start(net_dev->phydev);
26
27 netif_carrier_on(net_dev);
28 return 0;
29 @@ -1335,7 +1335,7 @@ static int bgmac_stop(struct net_device
30
31 netif_carrier_off(net_dev);
32
33 - phy_stop(bgmac->phy_dev);
34 + phy_stop(net_dev->phydev);
35
36 napi_disable(&bgmac->napi);
37 bgmac_chip_intrs_off(bgmac);
38 @@ -1373,12 +1373,10 @@ static int bgmac_set_mac_address(struct
39
40 static int bgmac_ioctl(struct net_device *net_dev, struct ifreq *ifr, int cmd)
41 {
42 - struct bgmac *bgmac = netdev_priv(net_dev);
43 -
44 if (!netif_running(net_dev))
45 return -EINVAL;
46
47 - return phy_mii_ioctl(bgmac->phy_dev, ifr, cmd);
48 + return phy_mii_ioctl(net_dev->phydev, ifr, cmd);
49 }
50
51 static const struct net_device_ops bgmac_netdev_ops = {
52 @@ -1521,7 +1519,7 @@ static int bgmac_get_settings(struct net
53 {
54 struct bgmac *bgmac = netdev_priv(net_dev);
55
56 - return phy_ethtool_gset(bgmac->phy_dev, cmd);
57 + return phy_ethtool_gset(net_dev->phydev, cmd);
58 }
59
60 static int bgmac_set_settings(struct net_device *net_dev,
61 @@ -1529,7 +1527,7 @@ static int bgmac_set_settings(struct net
62 {
63 struct bgmac *bgmac = netdev_priv(net_dev);
64
65 - return phy_ethtool_sset(bgmac->phy_dev, cmd);
66 + return phy_ethtool_sset(net_dev->phydev, cmd);
67 }
68
69 static void bgmac_get_drvinfo(struct net_device *net_dev,
70 @@ -1566,7 +1564,7 @@ static int bgmac_mii_write(struct mii_bu
71 static void bgmac_adjust_link(struct net_device *net_dev)
72 {
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;
76 bool update = false;
77
78 if (phy_dev->link) {
79 @@ -1610,8 +1608,6 @@ static int bgmac_fixed_phy_register(stru
80 return err;
81 }
82
83 - bgmac->phy_dev = phy_dev;
84 -
85 return err;
86 }
87
88 @@ -1664,7 +1660,6 @@ static int bgmac_mii_register(struct bgm
89 err = PTR_ERR(phy_dev);
90 goto err_unregister_bus;
91 }
92 - bgmac->phy_dev = phy_dev;
93
94 return err;
95
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;
103
104 /* DMA */
105 struct bgmac_dma_ring tx_ring[BGMAC_MAX_TX_RINGS];