linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: phylink: Remove redundant netdev.phydev assignment
@ 2018-02-23 15:25 Richard Cochran
  2018-03-01 18:26 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Cochran @ 2018-02-23 15:25 UTC (permalink / raw)
  To: netdev
  Cc: linux-kernel, Andrew Lunn, David Miller, Florian Fainelli, Russell King

As a part of working on MII time stamping infrastructure, I was trying
to figure out how netdev->phydev gets assigned, and I stumbled across
this.  Ever since the new phylink code came in, the field is assigned
twice.

The function, phylink_connect_phy(), calls

	phy_attach_direct()
	phylink_bringup_phy()

and phy_attach_direct() sets

	dev->phydev = phydev;

but phylink_bringup_phy() then sets the same field again:

	pl->netdev->phydev = phy;

Similarly, the function, phylink_of_phy_connect(), calls

	of_phy_attach()
		phy_attach_direct()
	phylink_bringup_phy()

The removal code is also duplicated:

phylink_disconnect_phy()
	pl->netdev->phydev = NULL;
	phy_disconnect()
		phy_detach()
			phydev->attached_dev->phydev = NULL;

This patch removes the redundant assignments, restricting manipulation
of the netdev.phydev field to phy_attach_direct() and phy_detach().

Signed-off-by: Richard Cochran <richardcochran@gmail.com>
---
 drivers/net/phy/phylink.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 6ac8b29b2dc3..867ffd654daf 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -679,7 +679,6 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)
 
 	mutex_lock(&phy->lock);
 	mutex_lock(&pl->state_mutex);
-	pl->netdev->phydev = phy;
 	pl->phydev = phy;
 	linkmode_copy(pl->supported, supported);
 	linkmode_copy(pl->link_config.advertising, config.advertising);
@@ -817,7 +816,6 @@ void phylink_disconnect_phy(struct phylink *pl)
 	if (phy) {
 		mutex_lock(&phy->lock);
 		mutex_lock(&pl->state_mutex);
-		pl->netdev->phydev = NULL;
 		pl->phydev = NULL;
 		mutex_unlock(&pl->state_mutex);
 		mutex_unlock(&phy->lock);
-- 
2.11.0

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

* Re: [PATCH net-next] net: phylink: Remove redundant netdev.phydev assignment
  2018-02-23 15:25 [PATCH net-next] net: phylink: Remove redundant netdev.phydev assignment Richard Cochran
@ 2018-03-01 18:26 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-03-01 18:26 UTC (permalink / raw)
  To: richardcochran; +Cc: netdev, linux-kernel, andrew, f.fainelli, linux

From: Richard Cochran <richardcochran@gmail.com>
Date: Fri, 23 Feb 2018 07:25:46 -0800

> As a part of working on MII time stamping infrastructure, I was trying
> to figure out how netdev->phydev gets assigned, and I stumbled across
> this.  Ever since the new phylink code came in, the field is assigned
> twice.
> 
> The function, phylink_connect_phy(), calls
> 
> 	phy_attach_direct()
> 	phylink_bringup_phy()
> 
> and phy_attach_direct() sets
> 
> 	dev->phydev = phydev;
> 
> but phylink_bringup_phy() then sets the same field again:
> 
> 	pl->netdev->phydev = phy;
> 
> Similarly, the function, phylink_of_phy_connect(), calls
> 
> 	of_phy_attach()
> 		phy_attach_direct()
> 	phylink_bringup_phy()
> 
> The removal code is also duplicated:
> 
> phylink_disconnect_phy()
> 	pl->netdev->phydev = NULL;
> 	phy_disconnect()
> 		phy_detach()
> 			phydev->attached_dev->phydev = NULL;
> 
> This patch removes the redundant assignments, restricting manipulation
> of the netdev.phydev field to phy_attach_direct() and phy_detach().
> 
> Signed-off-by: Richard Cochran <richardcochran@gmail.com>

Applied, thanks Richard.
 

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

end of thread, other threads:[~2018-03-01 18:26 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-23 15:25 [PATCH net-next] net: phylink: Remove redundant netdev.phydev assignment Richard Cochran
2018-03-01 18:26 ` 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).