linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: ethernet: ax88796: use phydev from struct net_device
@ 2016-06-15 22:12 Philippe Reynes
  2016-06-15 22:12 ` [PATCH 2/2] net: ethernet: ax88796: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
  2016-06-17  0:07 ` [PATCH 1/2] net: ethernet: ax88796: use phydev from struct net_device David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Philippe Reynes @ 2016-06-15 22:12 UTC (permalink / raw)
  To: andrew, davem, f.fainelli; +Cc: netdev, linux-kernel, Philippe Reynes

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>
---
 drivers/net/ethernet/8390/ax88796.c |   20 +++++++-------------
 1 files changed, 7 insertions(+), 13 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index c89b9ae..b446977 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -84,7 +84,6 @@ static u32 ax_msg_enable;
 struct ax_device {
 	struct mii_bus *mii_bus;
 	struct mdiobb_ctrl bb_ctrl;
-	struct phy_device *phy_dev;
 	void __iomem *addr_memr;
 	u8 reg_memr;
 	int link;
@@ -320,7 +319,7 @@ static void ax_block_output(struct net_device *dev, int count,
 static void ax_handle_link_change(struct net_device *dev)
 {
 	struct ax_device  *ax = to_ax_dev(dev);
-	struct phy_device *phy_dev = ax->phy_dev;
+	struct phy_device *phy_dev = dev->phydev;
 	int status_change = 0;
 
 	if (phy_dev->link && ((ax->speed != phy_dev->speed) ||
@@ -369,8 +368,6 @@ static int ax_mii_probe(struct net_device *dev)
 	phy_dev->supported &= PHY_BASIC_FEATURES;
 	phy_dev->advertising = phy_dev->supported;
 
-	ax->phy_dev = phy_dev;
-
 	netdev_info(dev, "PHY driver [%s] (mii_bus:phy_addr=%s, irq=%d)\n",
 		    phy_dev->drv->name, phydev_name(phy_dev), phy_dev->irq);
 
@@ -410,7 +407,7 @@ static int ax_open(struct net_device *dev)
 	ret = ax_mii_probe(dev);
 	if (ret)
 		goto failed_mii_probe;
-	phy_start(ax->phy_dev);
+	phy_start(dev->phydev);
 
 	ret = ax_ei_open(dev);
 	if (ret)
@@ -421,7 +418,7 @@ static int ax_open(struct net_device *dev)
 	return 0;
 
  failed_ax_ei_open:
-	phy_disconnect(ax->phy_dev);
+	phy_disconnect(dev->phydev);
  failed_mii_probe:
 	ax_phy_switch(dev, 0);
 	free_irq(dev->irq, dev);
@@ -442,7 +439,7 @@ static int ax_close(struct net_device *dev)
 
 	/* turn the phy off */
 	ax_phy_switch(dev, 0);
-	phy_disconnect(ax->phy_dev);
+	phy_disconnect(dev->phydev);
 
 	free_irq(dev->irq, dev);
 	return 0;
@@ -450,8 +447,7 @@ static int ax_close(struct net_device *dev)
 
 static int ax_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
 {
-	struct ax_device *ax = to_ax_dev(dev);
-	struct phy_device *phy_dev = ax->phy_dev;
+	struct phy_device *phy_dev = dev->phydev;
 
 	if (!netif_running(dev))
 		return -EINVAL;
@@ -476,8 +472,7 @@ static void ax_get_drvinfo(struct net_device *dev,
 
 static int ax_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-	struct ax_device *ax = to_ax_dev(dev);
-	struct phy_device *phy_dev = ax->phy_dev;
+	struct phy_device *phy_dev = dev->phydev;
 
 	if (!phy_dev)
 		return -ENODEV;
@@ -487,8 +482,7 @@ static int ax_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 
 static int ax_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-	struct ax_device *ax = to_ax_dev(dev);
-	struct phy_device *phy_dev = ax->phy_dev;
+	struct phy_device *phy_dev = dev->phydev;
 
 	if (!phy_dev)
 		return -ENODEV;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] net: ethernet: ax88796: use phy_ethtool_{get|set}_link_ksettings
  2016-06-15 22:12 [PATCH 1/2] net: ethernet: ax88796: use phydev from struct net_device Philippe Reynes
@ 2016-06-15 22:12 ` Philippe Reynes
  2016-06-17  0:07   ` David Miller
  2016-06-17  0:07 ` [PATCH 1/2] net: ethernet: ax88796: use phydev from struct net_device David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Reynes @ 2016-06-15 22:12 UTC (permalink / raw)
  To: andrew, davem, f.fainelli; +Cc: netdev, linux-kernel, Philippe Reynes

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 <tremyfr@gmail.com>
---
 drivers/net/ethernet/8390/ax88796.c |   24 ++----------------------
 1 files changed, 2 insertions(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/8390/ax88796.c b/drivers/net/ethernet/8390/ax88796.c
index b446977..5698f53 100644
--- a/drivers/net/ethernet/8390/ax88796.c
+++ b/drivers/net/ethernet/8390/ax88796.c
@@ -470,26 +470,6 @@ static void ax_get_drvinfo(struct net_device *dev,
 	strlcpy(info->bus_info, pdev->name, sizeof(info->bus_info));
 }
 
-static int ax_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-	struct phy_device *phy_dev = dev->phydev;
-
-	if (!phy_dev)
-		return -ENODEV;
-
-	return phy_ethtool_gset(phy_dev, cmd);
-}
-
-static int ax_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-	struct phy_device *phy_dev = dev->phydev;
-
-	if (!phy_dev)
-		return -ENODEV;
-
-	return phy_ethtool_sset(phy_dev, cmd);
-}
-
 static u32 ax_get_msglevel(struct net_device *dev)
 {
 	struct ei_device *ei_local = netdev_priv(dev);
@@ -506,12 +486,12 @@ static void ax_set_msglevel(struct net_device *dev, u32 v)
 
 static const struct ethtool_ops ax_ethtool_ops = {
 	.get_drvinfo		= ax_get_drvinfo,
-	.get_settings		= ax_get_settings,
-	.set_settings		= ax_set_settings,
 	.get_link		= ethtool_op_get_link,
 	.get_ts_info		= ethtool_op_get_ts_info,
 	.get_msglevel		= ax_get_msglevel,
 	.set_msglevel		= ax_set_msglevel,
+	.get_link_ksettings	= phy_ethtool_get_link_ksettings,
+	.set_link_ksettings	= phy_ethtool_set_link_ksettings,
 };
 
 #ifdef CONFIG_AX88796_93CX6
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] net: ethernet: ax88796: use phydev from struct net_device
  2016-06-15 22:12 [PATCH 1/2] net: ethernet: ax88796: use phydev from struct net_device Philippe Reynes
  2016-06-15 22:12 ` [PATCH 2/2] net: ethernet: ax88796: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-06-17  0:07 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-06-17  0:07 UTC (permalink / raw)
  To: tremyfr; +Cc: andrew, f.fainelli, netdev, linux-kernel

From: Philippe Reynes <tremyfr@gmail.com>
Date: Thu, 16 Jun 2016 00:12:48 +0200

> 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>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 2/2] net: ethernet: ax88796: use phy_ethtool_{get|set}_link_ksettings
  2016-06-15 22:12 ` [PATCH 2/2] net: ethernet: ax88796: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-06-17  0:07   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-06-17  0:07 UTC (permalink / raw)
  To: tremyfr; +Cc: andrew, f.fainelli, netdev, linux-kernel

From: Philippe Reynes <tremyfr@gmail.com>
Date: Thu, 16 Jun 2016 00:12:49 +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 <tremyfr@gmail.com>

Applied.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-06-17  0:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-06-15 22:12 [PATCH 1/2] net: ethernet: ax88796: use phydev from struct net_device Philippe Reynes
2016-06-15 22:12 ` [PATCH 2/2] net: ethernet: ax88796: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-06-17  0:07   ` David Miller
2016-06-17  0:07 ` [PATCH 1/2] net: ethernet: ax88796: use phydev from struct net_device David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).