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

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index 5138407..a7778d9 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -171,7 +171,6 @@ struct port {
 	struct npe *npe;
 	struct net_device *netdev;
 	struct napi_struct napi;
-	struct phy_device *phydev;
 	struct eth_plat_info *plat;
 	buffer_t *rx_buff_tab[RX_DESCS], *tx_buff_tab[TX_DESCS];
 	struct desc *desc_tab;	/* coherent */
@@ -562,7 +561,7 @@ static void ixp4xx_mdio_remove(void)
 static void ixp4xx_adjust_link(struct net_device *dev)
 {
 	struct port *port = netdev_priv(dev);
-	struct phy_device *phydev = port->phydev;
+	struct phy_device *phydev = dev->phydev;
 
 	if (!phydev->link) {
 		if (port->speed) {
@@ -976,8 +975,6 @@ static void eth_set_mcast_list(struct net_device *dev)
 
 static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
 {
-	struct port *port = netdev_priv(dev);
-
 	if (!netif_running(dev))
 		return -EINVAL;
 
@@ -988,7 +985,7 @@ static int eth_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
 			return hwtstamp_get(dev, req);
 	}
 
-	return phy_mii_ioctl(port->phydev, req, cmd);
+	return phy_mii_ioctl(dev->phydev, req, cmd);
 }
 
 /* ethtool support */
@@ -1007,20 +1004,17 @@ static void ixp4xx_get_drvinfo(struct net_device *dev,
 
 static int ixp4xx_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-	struct port *port = netdev_priv(dev);
-	return phy_ethtool_gset(port->phydev, cmd);
+	return phy_ethtool_gset(dev->phydev, cmd);
 }
 
 static int ixp4xx_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
 {
-	struct port *port = netdev_priv(dev);
-	return phy_ethtool_sset(port->phydev, cmd);
+	return phy_ethtool_sset(dev->phydev, cmd);
 }
 
 static int ixp4xx_nway_reset(struct net_device *dev)
 {
-	struct port *port = netdev_priv(dev);
-	return phy_start_aneg(port->phydev);
+	return phy_start_aneg(dev->phydev);
 }
 
 int ixp46x_phc_index = -1;
@@ -1259,7 +1253,7 @@ static int eth_open(struct net_device *dev)
 	}
 
 	port->speed = 0;	/* force "link up" message */
-	phy_start(port->phydev);
+	phy_start(dev->phydev);
 
 	for (i = 0; i < ETH_ALEN; i++)
 		__raw_writel(dev->dev_addr[i], &port->regs->hw_addr[i]);
@@ -1380,7 +1374,7 @@ static int eth_close(struct net_device *dev)
 		printk(KERN_CRIT "%s: unable to disable loopback\n",
 		       dev->name);
 
-	phy_stop(port->phydev);
+	phy_stop(dev->phydev);
 
 	if (!ports_open)
 		qmgr_disable_irq(TXDONE_QUEUE);
@@ -1405,6 +1399,7 @@ static int eth_init_one(struct platform_device *pdev)
 	struct port *port;
 	struct net_device *dev;
 	struct eth_plat_info *plat = dev_get_platdata(&pdev->dev);
+	struct phy_device *phydev = NULL;
 	u32 regs_phys;
 	char phy_id[MII_BUS_ID_SIZE + 3];
 	int err;
@@ -1466,14 +1461,14 @@ static int eth_init_one(struct platform_device *pdev)
 
 	snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
 		mdio_bus->id, plat->phy);
-	port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
-				   PHY_INTERFACE_MODE_MII);
-	if (IS_ERR(port->phydev)) {
-		err = PTR_ERR(port->phydev);
+	phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
+			     PHY_INTERFACE_MODE_MII);
+	if (IS_ERR(phydev)) {
+		err = PTR_ERR(phydev);
 		goto err_free_mem;
 	}
 
-	port->phydev->irq = PHY_POLL;
+	phydev->irq = PHY_POLL;
 
 	if ((err = register_netdev(dev)))
 		goto err_phy_dis;
@@ -1484,7 +1479,7 @@ static int eth_init_one(struct platform_device *pdev)
 	return 0;
 
 err_phy_dis:
-	phy_disconnect(port->phydev);
+	phy_disconnect(phydev);
 err_free_mem:
 	npe_port_tab[NPE_ID(port->id)] = NULL;
 	release_resource(port->mem_res);
@@ -1498,10 +1493,11 @@ err_free:
 static int eth_remove_one(struct platform_device *pdev)
 {
 	struct net_device *dev = platform_get_drvdata(pdev);
+	struct phy_device *phydev = dev->phydev;
 	struct port *port = netdev_priv(dev);
 
 	unregister_netdev(dev);
-	phy_disconnect(port->phydev);
+	phy_disconnect(phydev);
 	npe_port_tab[NPE_ID(port->id)] = NULL;
 	npe_release(port->npe);
 	release_resource(port->mem_res);
-- 
1.7.4.4

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

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

diff --git a/drivers/net/ethernet/xscale/ixp4xx_eth.c b/drivers/net/ethernet/xscale/ixp4xx_eth.c
index a7778d9..7f127dc 100644
--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
@@ -1002,16 +1002,6 @@ static void ixp4xx_get_drvinfo(struct net_device *dev,
 	strlcpy(info->bus_info, "internal", sizeof(info->bus_info));
 }
 
-static int ixp4xx_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-	return phy_ethtool_gset(dev->phydev, cmd);
-}
-
-static int ixp4xx_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
-{
-	return phy_ethtool_sset(dev->phydev, cmd);
-}
-
 static int ixp4xx_nway_reset(struct net_device *dev)
 {
 	return phy_start_aneg(dev->phydev);
@@ -1048,11 +1038,11 @@ static int ixp4xx_get_ts_info(struct net_device *dev,
 
 static const struct ethtool_ops ixp4xx_ethtool_ops = {
 	.get_drvinfo = ixp4xx_get_drvinfo,
-	.get_settings = ixp4xx_get_settings,
-	.set_settings = ixp4xx_set_settings,
 	.nway_reset = ixp4xx_nway_reset,
 	.get_link = ethtool_op_get_link,
 	.get_ts_info = ixp4xx_get_ts_info,
+	.get_link_ksettings = phy_ethtool_get_link_ksettings,
+	.set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
 
-- 
1.7.4.4

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

* Re: [PATCH 1/2] net: ethernet: ixp4xx_eth: use phydev from struct net_device
  2016-07-02 12:06 [PATCH 1/2] net: ethernet: ixp4xx_eth: use phydev from struct net_device Philippe Reynes
  2016-07-02 12:06 ` [PATCH 2/2] net: ethernet: ixp4xx_eth: 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: khalasa, netdev, linux-kernel

From: Philippe Reynes <tremyfr@gmail.com>
Date: Sat,  2 Jul 2016 14:06:14 +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: ixp4xx_eth: use phy_ethtool_{get|set}_link_ksettings
  2016-07-02 12:06 ` [PATCH 2/2] net: ethernet: ixp4xx_eth: 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: khalasa, netdev, linux-kernel

From: Philippe Reynes <tremyfr@gmail.com>
Date: Sat,  2 Jul 2016 14:06:15 +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:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-07-02 12:06 [PATCH 1/2] net: ethernet: ixp4xx_eth: use phydev from struct net_device Philippe Reynes
2016-07-02 12:06 ` [PATCH 2/2] net: ethernet: ixp4xx_eth: 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: ixp4xx_eth: 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).