netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King <rmk+kernel@armlinux.org.uk>
To: Andrew Lunn <andrew@lunn.ch>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Heiner Kallweit <hkallweit1@gmail.com>
Cc: "David S. Miller" <davem@davemloft.net>, netdev@vger.kernel.org
Subject: [PATCH net-next v2 07/14] net: phylink: re-split __phylink_connect_phy()
Date: Mon, 09 Dec 2019 15:19:01 +0000	[thread overview]
Message-ID: <E1ieKoP-0004vF-8F@rmk-PC.armlinux.org.uk> (raw)
In-Reply-To: <20191209151553.GP25745@shell.armlinux.org.uk>

In order to support Clause 45 PHYs on SFP+ modules, which have an
indeterminant phy interface mode, we need to be able to call
phylink_bringup_phy() with a different interface mode to that used when
binding the PHY. Reduce __phylink_connect_phy() to an attach operation,
and move the call to phylink_bringup_phy() to its call sites.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
---
 drivers/net/phy/phylink.c | 37 ++++++++++++++++++++++++-------------
 1 file changed, 24 insertions(+), 13 deletions(-)

diff --git a/drivers/net/phy/phylink.c b/drivers/net/phy/phylink.c
index 8c3fafebe667..c32b2c080584 100644
--- a/drivers/net/phy/phylink.c
+++ b/drivers/net/phy/phylink.c
@@ -764,8 +764,8 @@ static int phylink_bringup_phy(struct phylink *pl, struct phy_device *phy)
 	return 0;
 }
 
-static int __phylink_connect_phy(struct phylink *pl, struct phy_device *phy,
-		phy_interface_t interface)
+static int phylink_attach_phy(struct phylink *pl, struct phy_device *phy,
+			      phy_interface_t interface)
 {
 	int ret;
 
@@ -777,15 +777,7 @@ static int __phylink_connect_phy(struct phylink *pl, struct phy_device *phy,
 	if (pl->phydev)
 		return -EBUSY;
 
-	ret = phy_attach_direct(pl->netdev, phy, 0, interface);
-	if (ret)
-		return ret;
-
-	ret = phylink_bringup_phy(pl, phy);
-	if (ret)
-		phy_detach(phy);
-
-	return ret;
+	return phy_attach_direct(pl->netdev, phy, 0, interface);
 }
 
 /**
@@ -805,13 +797,23 @@ static int __phylink_connect_phy(struct phylink *pl, struct phy_device *phy,
  */
 int phylink_connect_phy(struct phylink *pl, struct phy_device *phy)
 {
+	int ret;
+
 	/* Use PHY device/driver interface */
 	if (pl->link_interface == PHY_INTERFACE_MODE_NA) {
 		pl->link_interface = phy->interface;
 		pl->link_config.interface = pl->link_interface;
 	}
 
-	return __phylink_connect_phy(pl, phy, pl->link_interface);
+	ret = phylink_attach_phy(pl, phy, pl->link_interface);
+	if (ret < 0)
+		return ret;
+
+	ret = phylink_bringup_phy(pl, phy);
+	if (ret)
+		phy_detach(phy);
+
+	return ret;
 }
 EXPORT_SYMBOL_GPL(phylink_connect_phy);
 
@@ -1812,8 +1814,17 @@ static void phylink_sfp_link_up(void *upstream)
 static int phylink_sfp_connect_phy(void *upstream, struct phy_device *phy)
 {
 	struct phylink *pl = upstream;
+	int ret;
+
+	ret = phylink_attach_phy(pl, phy, pl->link_config.interface);
+	if (ret < 0)
+		return ret;
+
+	ret = phylink_bringup_phy(pl, phy);
+	if (ret)
+		phy_detach(phy);
 
-	return __phylink_connect_phy(upstream, phy, pl->link_config.interface);
+	return ret;
 }
 
 static void phylink_sfp_disconnect_phy(void *upstream)
-- 
2.20.1


  parent reply	other threads:[~2019-12-09 15:19 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-12-09 15:15 [PATCH net-next v2 00/14] Add support for SFP+ copper modules Russell King - ARM Linux admin
2019-12-09 15:18 ` [PATCH net-next v2 01/14] net: sfp: remove incomplete 100BASE-FX and 100BASE-LX support Russell King
2019-12-10 16:52   ` Andrew Lunn
2019-12-09 15:18 ` [PATCH net-next v2 02/14] net: sfp: derive interface mode from ethtool link modes Russell King
2019-12-10 16:53   ` Andrew Lunn
2019-12-09 15:18 ` [PATCH net-next v2 03/14] net: sfp: add more extended compliance codes Russell King
2019-12-10 16:57   ` Andrew Lunn
2019-12-10 17:21     ` Russell King - ARM Linux admin
2019-12-09 15:18 ` [PATCH net-next v2 04/14] net: sfp: add module start/stop upstream notifications Russell King
2019-12-10 16:59   ` Andrew Lunn
2019-12-09 15:18 ` [PATCH net-next v2 05/14] net: sfp: move phy_start()/phy_stop() to phylink Russell King
2019-12-10 17:00   ` Andrew Lunn
2019-12-09 15:18 ` [PATCH net-next v2 06/14] net: mdio-i2c: add support for Clause 45 accesses Russell King
2019-12-10 17:05   ` Andrew Lunn
2019-12-09 15:19 ` Russell King [this message]
2019-12-10 17:06   ` [PATCH net-next v2 07/14] net: phylink: re-split __phylink_connect_phy() Andrew Lunn
2019-12-09 15:19 ` [PATCH net-next v2 08/14] net: phylink: support Clause 45 PHYs on SFP+ modules Russell King
2019-12-10 17:07   ` Andrew Lunn
2019-12-09 15:19 ` [PATCH net-next v2 09/14] net: phylink: split link_an_mode configured and current settings Russell King
2019-12-10 17:09   ` Andrew Lunn
2019-12-09 15:19 ` [PATCH net-next v2 10/14] net: phylink: split phylink_sfp_module_insert() Russell King
2019-12-10 17:10   ` Andrew Lunn
2019-12-09 15:19 ` [PATCH net-next v2 11/14] net: phylink: delay MAC configuration for copper SFP modules Russell King
2019-12-10 17:14   ` Andrew Lunn
2019-12-09 15:19 ` [PATCH net-next v2 12/14] net: phylink: make Broadcom BCM84881 based SFPs work Russell King
2019-12-10 17:32   ` Florian Fainelli
2019-12-09 15:19 ` [PATCH net-next v2 13/14] net: phy: add Broadcom BCM84881 PHY driver Russell King
2019-12-10 17:34   ` Florian Fainelli
2019-12-10 17:58     ` Russell King - ARM Linux admin
2019-12-10 18:46       ` Russell King - ARM Linux admin
2019-12-19  0:55         ` Russell King - ARM Linux admin
2019-12-19  0:57           ` Florian Fainelli
2019-12-09 15:19 ` [PATCH net-next v2 14/14] net: sfp: add support for Clause 45 PHYs Russell King
2019-12-10 17:21   ` Andrew Lunn
2019-12-11  1:23 ` [PATCH net-next v2 00/14] Add support for SFP+ copper modules David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E1ieKoP-0004vF-8F@rmk-PC.armlinux.org.uk \
    --to=rmk+kernel@armlinux.org.uk \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=f.fainelli@gmail.com \
    --cc=hkallweit1@gmail.com \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).