All of lore.kernel.org
 help / color / mirror / Atom feed
From: "David Rivshin (Allworx)" <drivshin.allworx@gmail.com>
To: netdev@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
	David Miller <davem@davemloft.net>,
	Markus Brunner <systemprogrammierung.brunner@gmail.com>,
	Mugunthan V N <mugunthanvnm@ti.com>,
	Pascal Speck <kernel@iktek.de>,
	Daniel Trautmann <dtrautmann@ibhsoftec-sps.de>
Subject: [PATCH v2 3/3] drivers: net: cpsw: increment reference count on fixed-link PHY node
Date: Wed, 16 Dec 2015 23:02:11 -0500	[thread overview]
Message-ID: <9a0128ebbc20ca9b911d24205408a38d8474725c.1450309613.git.drivshin@allworx.com> (raw)
In-Reply-To: <cover.1450309613.git.drivshin@allworx.com>

From: David Rivshin <drivshin@allworx.com>

When a fixed-link sub-node exists in a slave node, the slave node
is also the PHY node. Since this is a separate use of the slave node,
of_node_get() should be used to increment the reference count.

Fixes: 1f71e8c96fc6 ("drivers: net: cpsw: Add support for fixed-link PHY")
Signed-off-by: David Rivshin <drivshin@allworx.com>
---
'pd' was renamed to 'phy_dev' to better fit the naming convention in the
function/file.

 drivers/net/ethernet/ti/cpsw.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index bc6d20d..3b489ca 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2036,16 +2036,21 @@ static int cpsw_probe_dt(struct cpsw_priv *priv,
 		priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
 		parp = of_get_property(slave_node, "phy_id", &lenp);
 		if (of_phy_is_fixed_link(slave_node)) {
-			struct phy_device *pd;
+			struct device_node *phy_node;
+			struct phy_device *phy_dev;

+			/* In the case of a fixed PHY, the DT node associated
+			 * to the PHY is the Ethernet MAC DT node.
+			 */
 			ret = of_phy_register_fixed_link(slave_node);
 			if (ret)
 				return ret;
-			pd = of_phy_find_device(slave_node);
-			if (!pd)
+			phy_node = of_node_get(slave_node);
+			phy_dev = of_phy_find_device(phy_node);
+			if (!phy_dev)
 				return -ENODEV;
 			snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
-				 PHY_ID_FMT, pd->bus->id, pd->addr);
+				 PHY_ID_FMT, phy_dev->bus->id, phy_dev->addr);
 		} else if (parp) {
 			u32 phyid;
 			struct device_node *mdio_node;
--
2.5.0

WARNING: multiple messages have this Message-ID (diff)
From: drivshin.allworx@gmail.com (David Rivshin (Allworx))
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v2 3/3] drivers: net: cpsw: increment reference count on fixed-link PHY node
Date: Wed, 16 Dec 2015 23:02:11 -0500	[thread overview]
Message-ID: <9a0128ebbc20ca9b911d24205408a38d8474725c.1450309613.git.drivshin@allworx.com> (raw)
In-Reply-To: <cover.1450309613.git.drivshin@allworx.com>

From: David Rivshin <drivshin@allworx.com>

When a fixed-link sub-node exists in a slave node, the slave node
is also the PHY node. Since this is a separate use of the slave node,
of_node_get() should be used to increment the reference count.

Fixes: 1f71e8c96fc6 ("drivers: net: cpsw: Add support for fixed-link PHY")
Signed-off-by: David Rivshin <drivshin@allworx.com>
---
'pd' was renamed to 'phy_dev' to better fit the naming convention in the
function/file.

 drivers/net/ethernet/ti/cpsw.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index bc6d20d..3b489ca 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2036,16 +2036,21 @@ static int cpsw_probe_dt(struct cpsw_priv *priv,
 		priv->phy_node = of_parse_phandle(slave_node, "phy-handle", 0);
 		parp = of_get_property(slave_node, "phy_id", &lenp);
 		if (of_phy_is_fixed_link(slave_node)) {
-			struct phy_device *pd;
+			struct device_node *phy_node;
+			struct phy_device *phy_dev;

+			/* In the case of a fixed PHY, the DT node associated
+			 * to the PHY is the Ethernet MAC DT node.
+			 */
 			ret = of_phy_register_fixed_link(slave_node);
 			if (ret)
 				return ret;
-			pd = of_phy_find_device(slave_node);
-			if (!pd)
+			phy_node = of_node_get(slave_node);
+			phy_dev = of_phy_find_device(phy_node);
+			if (!phy_dev)
 				return -ENODEV;
 			snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
-				 PHY_ID_FMT, pd->bus->id, pd->addr);
+				 PHY_ID_FMT, phy_dev->bus->id, phy_dev->addr);
 		} else if (parp) {
 			u32 phyid;
 			struct device_node *mdio_node;
--
2.5.0

  parent reply	other threads:[~2015-12-17  4:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-10  3:31 [PATCH] drivers: net: cpsw: fix RMII/RGMII mode when used with fixed-link PHY David Rivshin (Allworx)
2015-12-10  3:31 ` David Rivshin (Allworx)
2015-12-12 15:44 ` Markus Brunner
2015-12-12 15:44   ` Markus Brunner
2015-12-14 18:04   ` David Rivshin (Allworx)
2015-12-14 18:04     ` David Rivshin (Allworx)
2015-12-16  6:39     ` Markus Brunner
2015-12-16  6:39       ` Markus Brunner
2015-12-17  4:02       ` [PATCH v2 0/3] drivers: net: cpsw: Fix bugs in fixed-link PHY DT parsing David Rivshin (Allworx)
2015-12-17  4:02         ` David Rivshin (Allworx)
2015-12-04 15:55         ` [PATCH] ethernet:ti:cpsw: fix phy identification with multiple slaves on fixed-phy Pascal Speck (Iktek)
2015-12-17  4:02           ` [PATCH v2 1/3] " David Rivshin (Allworx)
2015-12-17  4:02             ` David Rivshin (Allworx)
2015-12-17  4:02         ` [PATCH v2 2/3] drivers: net: cpsw: fix RMII/RGMII mode when used with fixed-link PHY David Rivshin (Allworx)
2015-12-17  4:02           ` David Rivshin (Allworx)
2015-12-17  4:02         ` David Rivshin (Allworx) [this message]
2015-12-17  4:02           ` [PATCH v2 3/3] drivers: net: cpsw: increment reference count on fixed-link PHY node David Rivshin (Allworx)
2015-12-17 20:45         ` [PATCH v2 0/3] drivers: net: cpsw: Fix bugs in fixed-link PHY DT parsing David Miller
2015-12-17 20:45           ` David Miller
2015-12-18 10:20           ` Daniel Trautmann
2015-12-18 10:20             ` Daniel Trautmann
2015-12-18 22:06             ` David Rivshin (Allworx)
2015-12-18 22:06               ` David Rivshin (Allworx)
2015-12-18 22:06               ` David Rivshin (Allworx)
2015-12-18 19:46         ` David Miller
2015-12-18 19:46           ` David Miller
2015-12-17  5:04       ` [PATCH] drivers: net: cpsw: fix RMII/RGMII mode when used with fixed-link PHY David Rivshin (Allworx)
2015-12-17  5:04         ` David Rivshin (Allworx)

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=9a0128ebbc20ca9b911d24205408a38d8474725c.1450309613.git.drivshin@allworx.com \
    --to=drivshin.allworx@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dtrautmann@ibhsoftec-sps.de \
    --cc=kernel@iktek.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=mugunthanvnm@ti.com \
    --cc=netdev@vger.kernel.org \
    --cc=systemprogrammierung.brunner@gmail.com \
    /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.