linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] net: ethernet: arc: emac: use phydev from struct net_device
@ 2016-07-02 18:06 Philippe Reynes
  2016-07-02 18:06 ` [PATCH 2/2] net: ethernet: arc: emac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
  2016-07-04 23:00 ` [PATCH 1/2] net: ethernet: arc: emac: use phydev from struct net_device David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Philippe Reynes @ 2016-07-02 18:06 UTC (permalink / raw)
  To: davem, wxt, heiko, al.kochet; +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
phy 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/arc/emac.h      |    1 -
 drivers/net/ethernet/arc/emac_main.c |   29 ++++++++++++-----------------
 2 files changed, 12 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/arc/emac.h b/drivers/net/ethernet/arc/emac.h
index ca562bc..e4feb71 100644
--- a/drivers/net/ethernet/arc/emac.h
+++ b/drivers/net/ethernet/arc/emac.h
@@ -134,7 +134,6 @@ struct arc_emac_priv {
 
 	/* Devices */
 	struct device *dev;
-	struct phy_device *phy_dev;
 	struct mii_bus *bus;
 	struct arc_emac_mdio_bus_data bus_data;
 
diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index a3a9392..a8a1dc9 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -47,7 +47,7 @@ static inline int arc_emac_tx_avail(struct arc_emac_priv *priv)
 static void arc_emac_adjust_link(struct net_device *ndev)
 {
 	struct arc_emac_priv *priv = netdev_priv(ndev);
-	struct phy_device *phy_dev = priv->phy_dev;
+	struct phy_device *phy_dev = ndev->phydev;
 	unsigned int reg, state_changed = 0;
 
 	if (priv->link != phy_dev->link) {
@@ -92,9 +92,7 @@ static void arc_emac_adjust_link(struct net_device *ndev)
 static int arc_emac_get_settings(struct net_device *ndev,
 				 struct ethtool_cmd *cmd)
 {
-	struct arc_emac_priv *priv = netdev_priv(ndev);
-
-	return phy_ethtool_gset(priv->phy_dev, cmd);
+	return phy_ethtool_gset(ndev->phydev, cmd);
 }
 
 /**
@@ -111,12 +109,10 @@ static int arc_emac_get_settings(struct net_device *ndev,
 static int arc_emac_set_settings(struct net_device *ndev,
 				 struct ethtool_cmd *cmd)
 {
-	struct arc_emac_priv *priv = netdev_priv(ndev);
-
 	if (!capable(CAP_NET_ADMIN))
 		return -EPERM;
 
-	return phy_ethtool_sset(priv->phy_dev, cmd);
+	return phy_ethtool_sset(ndev->phydev, cmd);
 }
 
 /**
@@ -403,7 +399,7 @@ static void arc_emac_poll_controller(struct net_device *dev)
 static int arc_emac_open(struct net_device *ndev)
 {
 	struct arc_emac_priv *priv = netdev_priv(ndev);
-	struct phy_device *phy_dev = priv->phy_dev;
+	struct phy_device *phy_dev = ndev->phydev;
 	int i;
 
 	phy_dev->autoneg = AUTONEG_ENABLE;
@@ -474,7 +470,7 @@ static int arc_emac_open(struct net_device *ndev)
 	/* Enable EMAC */
 	arc_reg_or(priv, R_CTRL, EN_MASK);
 
-	phy_start_aneg(priv->phy_dev);
+	phy_start_aneg(ndev->phydev);
 
 	netif_start_queue(ndev);
 
@@ -772,6 +768,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
 	struct device *dev = ndev->dev.parent;
 	struct resource res_regs;
 	struct device_node *phy_node;
+	struct phy_device *phydev = NULL;
 	struct arc_emac_priv *priv;
 	const char *mac_addr;
 	unsigned int id, clock_frequency, irq;
@@ -887,16 +884,16 @@ int arc_emac_probe(struct net_device *ndev, int interface)
 		goto out_clken;
 	}
 
-	priv->phy_dev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0,
-				       interface);
-	if (!priv->phy_dev) {
+	phydev = of_phy_connect(ndev, phy_node, arc_emac_adjust_link, 0,
+				interface);
+	if (!phydev) {
 		dev_err(dev, "of_phy_connect() failed\n");
 		err = -ENODEV;
 		goto out_mdio;
 	}
 
 	dev_info(dev, "connected to %s phy with id 0x%x\n",
-		 priv->phy_dev->drv->name, priv->phy_dev->phy_id);
+		 phydev->drv->name, phydev->phy_id);
 
 	netif_napi_add(ndev, &priv->napi, arc_emac_poll, ARC_EMAC_NAPI_WEIGHT);
 
@@ -910,8 +907,7 @@ int arc_emac_probe(struct net_device *ndev, int interface)
 
 out_netif_api:
 	netif_napi_del(&priv->napi);
-	phy_disconnect(priv->phy_dev);
-	priv->phy_dev = NULL;
+	phy_disconnect(phydev);
 out_mdio:
 	arc_mdio_remove(priv);
 out_clken:
@@ -925,8 +921,7 @@ int arc_emac_remove(struct net_device *ndev)
 {
 	struct arc_emac_priv *priv = netdev_priv(ndev);
 
-	phy_disconnect(priv->phy_dev);
-	priv->phy_dev = NULL;
+	phy_disconnect(ndev->phydev);
 	arc_mdio_remove(priv);
 	unregister_netdev(ndev);
 	netif_napi_del(&priv->napi);
-- 
1.7.4.4

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

* [PATCH 2/2] net: ethernet: arc: emac: use phy_ethtool_{get|set}_link_ksettings
  2016-07-02 18:06 [PATCH 1/2] net: ethernet: arc: emac: use phydev from struct net_device Philippe Reynes
@ 2016-07-02 18:06 ` Philippe Reynes
  2016-07-04 23:00   ` David Miller
  2016-07-04 23:00 ` [PATCH 1/2] net: ethernet: arc: emac: use phydev from struct net_device David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Philippe Reynes @ 2016-07-02 18:06 UTC (permalink / raw)
  To: davem, wxt, heiko, al.kochet; +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/arc/emac_main.c |   40 +--------------------------------
 1 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/drivers/net/ethernet/arc/emac_main.c b/drivers/net/ethernet/arc/emac_main.c
index a8a1dc9..586beda 100644
--- a/drivers/net/ethernet/arc/emac_main.c
+++ b/drivers/net/ethernet/arc/emac_main.c
@@ -80,42 +80,6 @@ static void arc_emac_adjust_link(struct net_device *ndev)
 }
 
 /**
- * arc_emac_get_settings - Get PHY settings.
- * @ndev:	Pointer to net_device structure.
- * @cmd:	Pointer to ethtool_cmd structure.
- *
- * This implements ethtool command for getting PHY settings. If PHY could
- * not be found, the function returns -ENODEV. This function calls the
- * relevant PHY ethtool API to get the PHY settings.
- * Issue "ethtool ethX" under linux prompt to execute this function.
- */
-static int arc_emac_get_settings(struct net_device *ndev,
-				 struct ethtool_cmd *cmd)
-{
-	return phy_ethtool_gset(ndev->phydev, cmd);
-}
-
-/**
- * arc_emac_set_settings - Set PHY settings as passed in the argument.
- * @ndev:	Pointer to net_device structure.
- * @cmd:	Pointer to ethtool_cmd structure.
- *
- * This implements ethtool command for setting various PHY settings. If PHY
- * could not be found, the function returns -ENODEV. This function calls the
- * relevant PHY ethtool API to set the PHY.
- * Issue e.g. "ethtool -s ethX speed 1000" under linux prompt to execute this
- * function.
- */
-static int arc_emac_set_settings(struct net_device *ndev,
-				 struct ethtool_cmd *cmd)
-{
-	if (!capable(CAP_NET_ADMIN))
-		return -EPERM;
-
-	return phy_ethtool_sset(ndev->phydev, cmd);
-}
-
-/**
  * arc_emac_get_drvinfo - Get EMAC driver information.
  * @ndev:	Pointer to net_device structure.
  * @info:	Pointer to ethtool_drvinfo structure.
@@ -133,10 +97,10 @@ static void arc_emac_get_drvinfo(struct net_device *ndev,
 }
 
 static const struct ethtool_ops arc_emac_ethtool_ops = {
-	.get_settings	= arc_emac_get_settings,
-	.set_settings	= arc_emac_set_settings,
 	.get_drvinfo	= arc_emac_get_drvinfo,
 	.get_link	= ethtool_op_get_link,
+	.get_link_ksettings = phy_ethtool_get_link_ksettings,
+	.set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
 #define FIRST_OR_LAST_MASK	(FIRST_MASK | LAST_MASK)
-- 
1.7.4.4

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

* Re: [PATCH 1/2] net: ethernet: arc: emac: use phydev from struct net_device
  2016-07-02 18:06 [PATCH 1/2] net: ethernet: arc: emac: use phydev from struct net_device Philippe Reynes
  2016-07-02 18:06 ` [PATCH 2/2] net: ethernet: arc: emac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-07-04 23:00 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2016-07-04 23:00 UTC (permalink / raw)
  To: tremyfr; +Cc: wxt, heiko, al.kochet, netdev, linux-kernel

From: Philippe Reynes <tremyfr@gmail.com>
Date: Sat,  2 Jul 2016 20:06:51 +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 <tremyfr@gmail.com>

Applied.

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

* Re: [PATCH 2/2] net: ethernet: arc: emac: use phy_ethtool_{get|set}_link_ksettings
  2016-07-02 18:06 ` [PATCH 2/2] net: ethernet: arc: emac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
@ 2016-07-04 23:00   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2016-07-04 23:00 UTC (permalink / raw)
  To: tremyfr; +Cc: wxt, heiko, al.kochet, netdev, linux-kernel

From: Philippe Reynes <tremyfr@gmail.com>
Date: Sat,  2 Jul 2016 20:06:52 +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-07-04 23:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-02 18:06 [PATCH 1/2] net: ethernet: arc: emac: use phydev from struct net_device Philippe Reynes
2016-07-02 18:06 ` [PATCH 2/2] net: ethernet: arc: emac: use phy_ethtool_{get|set}_link_ksettings Philippe Reynes
2016-07-04 23:00   ` David Miller
2016-07-04 23:00 ` [PATCH 1/2] net: ethernet: arc: emac: 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).