[PATCH 1/2] net: ethernet: hix5hd2: use phydev from struct net_device

Subsystems: hisilicon network subsystem driver, networking drivers, the rest

STALE3700d

4 messages, 2 authors, 2016-06-28 · open the first message on its own page

[PATCH 1/2] net: ethernet: hix5hd2: use phydev from struct net_device

From: Philippe Reynes <hidden>
Date: 2016-06-25 14:55:30

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 <redacted>
---
 drivers/net/ethernet/hisilicon/hix5hd2_gmac.c |   30 ++++++++++--------------
 1 files changed, 13 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index b9f2ea5..fed1c0f 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -218,7 +218,6 @@ struct hix5hd2_priv {
 	struct device *dev;
 	struct net_device *netdev;
 
-	struct phy_device *phy;
 	struct device_node *phy_node;
 	phy_interface_t	phy_mode;
 
@@ -402,7 +401,7 @@ static int hix5hd2_net_set_mac_address(struct net_device *dev, void *p)
 static void hix5hd2_adjust_link(struct net_device *dev)
 {
 	struct hix5hd2_priv *priv = netdev_priv(dev);
-	struct phy_device *phy = priv->phy;
+	struct phy_device *phy = dev->phydev;
 
 	if ((priv->speed != phy->speed) || (priv->duplex != phy->duplex)) {
 		hix5hd2_config_port(dev, phy->speed, phy->duplex);
@@ -679,6 +678,7 @@ static void hix5hd2_free_dma_desc_rings(struct hix5hd2_priv *priv)
 static int hix5hd2_net_open(struct net_device *dev)
 {
 	struct hix5hd2_priv *priv = netdev_priv(dev);
+	struct phy_device *phy;
 	int ret;
 
 	ret = clk_prepare_enable(priv->clk);
@@ -687,12 +687,12 @@ static int hix5hd2_net_open(struct net_device *dev)
 		return ret;
 	}
 
-	priv->phy = of_phy_connect(dev, priv->phy_node,
-				   &hix5hd2_adjust_link, 0, priv->phy_mode);
-	if (!priv->phy)
+	phy = of_phy_connect(dev, priv->phy_node,
+			     &hix5hd2_adjust_link, 0, priv->phy_mode);
+	if (!phy)
 		return -ENODEV;
 
-	phy_start(priv->phy);
+	phy_start(phy);
 	hix5hd2_hw_init(priv);
 	hix5hd2_rx_refill(priv);
 
@@ -716,9 +716,9 @@ static int hix5hd2_net_close(struct net_device *dev)
 	netif_stop_queue(dev);
 	hix5hd2_free_dma_desc_rings(priv);
 
-	if (priv->phy) {
-		phy_stop(priv->phy);
-		phy_disconnect(priv->phy);
+	if (dev->phydev) {
+		phy_stop(dev->phydev);
+		phy_disconnect(dev->phydev);
 	}
 
 	clk_disable_unprepare(priv->clk);
@@ -753,23 +753,19 @@ static const struct net_device_ops hix5hd2_netdev_ops = {
 static int hix5hd2_get_settings(struct net_device *net_dev,
 				struct ethtool_cmd *cmd)
 {
-	struct hix5hd2_priv *priv = netdev_priv(net_dev);
-
-	if (!priv->phy)
+	if (!net_dev->phydev)
 		return -ENODEV;
 
-	return phy_ethtool_gset(priv->phy, cmd);
+	return phy_ethtool_gset(net_dev->phydev, cmd);
 }
 
 static int hix5hd2_set_settings(struct net_device *net_dev,
 				struct ethtool_cmd *cmd)
 {
-	struct hix5hd2_priv *priv = netdev_priv(net_dev);
-
-	if (!priv->phy)
+	if (!net_dev->phydev)
 		return -ENODEV;
 
-	return phy_ethtool_sset(priv->phy, cmd);
+	return phy_ethtool_sset(net_dev->phydev, cmd);
 }
 
 static struct ethtool_ops hix5hd2_ethtools_ops = {
-- 
1.7.4.4

[PATCH 2/2] net: ethernet: hix5hd2: use phy_ethtool_{get|set}_link_ksettings

From: Philippe Reynes <hidden>
Date: 2016-06-25 14:55:29

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 <redacted>
---
 drivers/net/ethernet/hisilicon/hix5hd2_gmac.c |   22 ++--------------------
 1 files changed, 2 insertions(+), 20 deletions(-)
diff --git a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
index fed1c0f..275618b 100644
--- a/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
+++ b/drivers/net/ethernet/hisilicon/hix5hd2_gmac.c
@@ -750,28 +750,10 @@ static const struct net_device_ops hix5hd2_netdev_ops = {
 	.ndo_set_mac_address	= hix5hd2_net_set_mac_address,
 };
 
-static int hix5hd2_get_settings(struct net_device *net_dev,
-				struct ethtool_cmd *cmd)
-{
-	if (!net_dev->phydev)
-		return -ENODEV;
-
-	return phy_ethtool_gset(net_dev->phydev, cmd);
-}
-
-static int hix5hd2_set_settings(struct net_device *net_dev,
-				struct ethtool_cmd *cmd)
-{
-	if (!net_dev->phydev)
-		return -ENODEV;
-
-	return phy_ethtool_sset(net_dev->phydev, cmd);
-}
-
 static struct ethtool_ops hix5hd2_ethtools_ops = {
 	.get_link		= ethtool_op_get_link,
-	.get_settings		= hix5hd2_get_settings,
-	.set_settings		= hix5hd2_set_settings,
+	.get_link_ksettings     = phy_ethtool_get_link_ksettings,
+	.set_link_ksettings     = phy_ethtool_set_link_ksettings,
 };
 
 static int hix5hd2_mdio_wait_ready(struct mii_bus *bus)
-- 
1.7.4.4

Re: [PATCH 1/2] net: ethernet: hix5hd2: use phydev from struct net_device

From: David Miller <davem@davemloft.net>
Date: 2016-06-28 13:14:12

From: Philippe Reynes <redacted>
Date: Sat, 25 Jun 2016 16:55:12 +0200
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 <redacted>
Applied.

Re: [PATCH 2/2] net: ethernet: hix5hd2: use phy_ethtool_{get|set}_link_ksettings

From: David Miller <davem@davemloft.net>
Date: 2016-06-28 13:14:44

From: Philippe Reynes <redacted>
Date: Sat, 25 Jun 2016 16:55:13 +0200
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 <redacted>
Applied.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help