All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stas Sergeev <stsp@list.ru>
To: netdev@vger.kernel.org
Cc: Linux kernel <linux-kernel@vger.kernel.org>,
	Stas Sergeev <stsp@users.sourceforge.net>,
	Florian Fainelli <f.fainelli@gmail.com>,
	Grant Likely <grant.likely@linaro.org>,
	Rob Herring <robh+dt@kernel.org>,
	devicetree@vger.kernel.org
Subject: [PATCH 3/6] of_mdio: restructure of_phy_register_fixed_link() for further modifications
Date: Fri, 27 Mar 2015 16:35:56 +0300	[thread overview]
Message-ID: <55155CBC.6010402@list.ru> (raw)
In-Reply-To: <55155AFC.4050800@list.ru>


This is a no-op patch needed to separate code rearrangements from
the actual changes. It allows to easily add code to the function
without duplicating it for new and old fixed-phy DT binding.
The subsequent patch therefore happily adds the code without duplications.

CC: Florian Fainelli <f.fainelli@gmail.com>
CC: Grant Likely <grant.likely@linaro.org>
CC: Rob Herring <robh+dt@kernel.org>
CC: netdev@vger.kernel.org
CC: devicetree@vger.kernel.org
CC: linux-kernel@vger.kernel.org

Signed-off-by: Stas Sergeev <stsp@users.sourceforge.net>
---
 drivers/of/of_mdio.c |   32 ++++++++++++++++++--------------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 1bd4305..b3dc1e6 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -301,22 +301,26 @@ int of_phy_register_fixed_link(struct device_node *np)
 							  "asym-pause");
 		of_node_put(fixed_link_node);
 		phy = fixed_phy_register(PHY_POLL, &status, np);
-		return IS_ERR(phy) ? PTR_ERR(phy) : 0;
-	}
-
-	/* Old binding */
-	fixed_link_prop = of_get_property(np, "fixed-link", &len);
-	if (fixed_link_prop && len == (5 * sizeof(__be32))) {
-		status.link = 1;
-		status.duplex = be32_to_cpu(fixed_link_prop[1]);
-		status.speed = be32_to_cpu(fixed_link_prop[2]);
-		status.pause = be32_to_cpu(fixed_link_prop[3]);
-		status.asym_pause = be32_to_cpu(fixed_link_prop[4]);
-		phy = fixed_phy_register(PHY_POLL, &status, np);
-		return IS_ERR(phy) ? PTR_ERR(phy) : 0;
+		if (IS_ERR(phy))
+			return PTR_ERR(phy);
+	} else {
+		/* Old binding */
+		fixed_link_prop = of_get_property(np, "fixed-link", &len);
+		if (fixed_link_prop && len == (5 * sizeof(__be32))) {
+			status.link = 1;
+			status.duplex = be32_to_cpu(fixed_link_prop[1]);
+			status.speed = be32_to_cpu(fixed_link_prop[2]);
+			status.pause = be32_to_cpu(fixed_link_prop[3]);
+			status.asym_pause = be32_to_cpu(fixed_link_prop[4]);
+			phy = fixed_phy_register(PHY_POLL, &status, np);
+			if (IS_ERR(phy))
+				return PTR_ERR(phy);
+		} else {
+			return -ENODEV;
+		}
 	}

-	return -ENODEV;
+	return 0;
 }
 EXPORT_SYMBOL(of_phy_register_fixed_link);
 #endif
-- 
1.7.9.5

  parent reply	other threads:[~2015-03-27 13:36 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-27 13:28 [PATCH 0/6] mvneta: SGMII-based in-band link state signaling Stas Sergeev
2015-03-27 13:31 ` PATCH 1/6] fixed_phy: pass phy_device instead of net_device to link_update() function Stas Sergeev
2015-03-27 13:33 ` [PATCH 2/6] fixed_phy: add fixed_phy_unregister() Stas Sergeev
2015-03-27 13:34 ` [PATCH 1/6] fixed_phy: pass phy_device instead of net_device to link_update() function Stas Sergeev
2015-03-27 13:35 ` Stas Sergeev [this message]
2015-03-27 13:37 ` [PATCH 4/6] of: add API for changing parameters of fixed link Stas Sergeev
2015-03-27 15:41   ` Florian Fainelli
2015-03-27 15:41     ` Florian Fainelli
2015-03-27 16:07     ` Stas Sergeev
2015-03-27 16:21       ` Florian Fainelli
2015-03-27 16:39         ` Stas Sergeev
2015-03-27 16:39           ` Stas Sergeev
2015-03-27 17:15           ` Florian Fainelli
2015-03-27 17:31             ` Stas Sergeev
2015-03-30 14:39             ` Stas Sergeev
2015-03-30 16:06               ` Florian Fainelli
2015-03-30 17:04                 ` Stas Sergeev
2015-03-31 17:11                 ` Stas Sergeev
2015-03-27 13:39 ` [PATCH 0/6] mvneta: SGMII-based in-band link state signaling Andrew Lunn
2015-03-27 13:52   ` Stas Sergeev
2015-03-27 13:59     ` Andrew Lunn
2015-03-27 14:20       ` Stas Sergeev
2015-03-27 15:44         ` Florian Fainelli
2015-03-27 13:39 ` [PATCH 5/6] mvneta: implement " Stas Sergeev
2015-07-08 16:30   ` [5/6] " Sebastien Rannou
2015-07-08 16:51     ` Stas Sergeev
2015-07-09  9:03       ` Sebastien Rannou
2015-07-09  9:19         ` Thomas Petazzoni
2015-07-09 10:11           ` Stas Sergeev
2015-03-27 13:40 ` [PATCH 6/6] mvneta: port marvell's official in-band status enabling procedure Stas Sergeev

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=55155CBC.6010402@list.ru \
    --to=stsp@list.ru \
    --cc=devicetree@vger.kernel.org \
    --cc=f.fainelli@gmail.com \
    --cc=grant.likely@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=robh+dt@kernel.org \
    --cc=stsp@users.sourceforge.net \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.