net: ethernet: bgmac: use phydev from struct net_device
Subsystems (3)
PATCH 1/2 net: ethernet: bgmac: 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 phydev in the private structure, and update the driver to use the one contained in struct net_device.
--- drivers/net/ethernet/broadcom/bgmac.c | 17 ++++++----------- drivers/net/ethernet/broadcom/bgmac.h | 1 - 2 files changed, 6 insertions(+), 12 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +6 -11
@@ -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 ;
@@ -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);
@@ -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 = {
@@ -1518,7 +1516,7 @@ 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,
@@ -1526,7 +1524,7 @@ static int bgmac_set_settings(struct net_device *net_dev, {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,
@@ -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) {
@@ -1607,8 +1605,6 @@ static int bgmac_fixed_phy_register(struct bgmac *bgmac)return err; } - bgmac->phy_dev = phy_dev; -return err; }
@@ -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;
drivers/net/ethernet/broadcom/bgmac.h +0 -1
@@ -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 ];
Signature · 1 line
1.7.4.4
PATCH 2/2 net: ethernet: bgmac: use phy_ethtool_{get|set}_link_ksettings
There are two generics functions phy_ethtool_{get|set}_link_ksettings, so we can use them instead of defining the same code in the driver.
--- drivers/net/ethernet/broadcom/bgmac.c | 20 ++------------------ 1 files changed, 2 insertions(+), 18 deletions(-)
drivers/net/ethernet/broadcom/bgmac.c +2 -18
@@ -1511,22 +1511,6 @@ static void bgmac_get_ethtool_stats(struct net_device *dev, } } -static int bgmac_get_settings (struct net_device *net_dev, -struct ethtool_cmd *cmd) -{ -struct bgmac *bgmac =netdev_priv (net_dev); - -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 (net_dev->phydev, cmd); -} -static void bgmac_get_drvinfo (struct net_device *net_dev,struct ethtool_drvinfo *info) {
@@ -1538,9 +1522,9 @@ static const struct ethtool_ops bgmac_ethtool_ops = { .get_strings = bgmac_get_strings, .get_sset_count = bgmac_get_sset_count, .get_ethtool_stats = bgmac_get_ethtool_stats, - .get_settings = bgmac_get_settings, - .set_settings = bgmac_set_settings, .get_drvinfo = bgmac_get_drvinfo, + .get_link_ksettings = phy_ethtool_get_link_ksettings, + .set_link_ksettings = phy_ethtool_set_link_ksettings, };/**************************************************
Signature · 1 line
1.7.4.4
Re: [PATCH 2/2] net: ethernet: bgmac: use phy_ethtool_{get|set}_link_ksettings
From: Philippe Reynes <[email protected]>
Date: Sun, 19 Jun 2016 22:37:06 +0200
Quoted 4 lines
There are two generics functions phy_ethtool_{get|set}_link_ksettings, so we can use them instead of defining the same code in the driver.
Signed-off-by Philippe Reynes <[email protected]>
Applied.
From: Philippe Reynes <[email protected]>
Date: Sun, 19 Jun 2016 22:37:05 +0200
Quoted 6 lines
The private structure contain a pointer to phydev, but the structure
net_devicealready contain such pointer. So we can remove the pointer phydev in the private structure, and update the driver to use the one contained in structnet_device.Signed-off-by Philippe Reynes <[email protected]>
Applied.