netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tony Lindgren <tony@atomide.com>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, linux-omap@vger.kernel.org,
	Brian Hutchinson <b.hutchman@gmail.com>,
	Felipe Balbi <balbi@ti.com>
Subject: [PATCH 4/6] net: davinci_emac: Fix incomplete code for getting the phy from device tree
Date: Tue, 13 Jan 2015 11:29:26 -0800	[thread overview]
Message-ID: <1421177368-19756-5-git-send-email-tony@atomide.com> (raw)
In-Reply-To: <1421177368-19756-1-git-send-email-tony@atomide.com>

Looks like the phy_id is never set up beyond getting the phandle.
Note that we can remove the ifdef for phy_node as there is a stub
for of_phy_connec() if CONFIG_OF is not set.

Cc: Brian Hutchinson <b.hutchman@gmail.com>
Cc: Felipe Balbi <balbi@ti.com>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 drivers/net/ethernet/ti/davinci_emac.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c
index e9efc74..4c8d82c 100644
--- a/drivers/net/ethernet/ti/davinci_emac.c
+++ b/drivers/net/ethernet/ti/davinci_emac.c
@@ -62,6 +62,7 @@
 #include <linux/of.h>
 #include <linux/of_address.h>
 #include <linux/of_device.h>
+#include <linux/of_mdio.h>
 #include <linux/of_irq.h>
 #include <linux/of_net.h>
 
@@ -343,9 +344,7 @@ struct emac_priv {
 	u32 multicast_hash_cnt[EMAC_NUM_MULTICAST_BITS];
 	u32 rx_addr_type;
 	const char *phy_id;
-#ifdef CONFIG_OF
 	struct device_node *phy_node;
-#endif
 	struct phy_device *phydev;
 	spinlock_t lock;
 	/*platform specific members*/
@@ -1597,8 +1596,20 @@ static int emac_dev_open(struct net_device *ndev)
 	cpdma_ctlr_start(priv->dma);
 
 	priv->phydev = NULL;
+
+	if (priv->phy_node) {
+		priv->phydev = of_phy_connect(ndev, priv->phy_node,
+					      &emac_adjust_link, 0, 0);
+		if (!priv->phydev) {
+			dev_err(emac_dev, "could not connect to phy %s\n",
+				priv->phy_node->full_name);
+			ret = -ENODEV;
+			goto err;
+		}
+	}
+
 	/* use the first phy on the bus if pdata did not give us a phy id */
-	if (!priv->phy_id) {
+	if (!priv->phydev && !priv->phy_id) {
 		struct device *phy;
 
 		phy = bus_find_device(&mdio_bus_type, NULL, NULL,
@@ -1607,7 +1618,7 @@ static int emac_dev_open(struct net_device *ndev)
 			priv->phy_id = dev_name(phy);
 	}
 
-	if (priv->phy_id && *priv->phy_id) {
+	if (!priv->phydev && priv->phy_id && *priv->phy_id) {
 		priv->phydev = phy_connect(ndev, priv->phy_id,
 					   &emac_adjust_link,
 					   PHY_INTERFACE_MODE_MII);
@@ -1628,7 +1639,9 @@ static int emac_dev_open(struct net_device *ndev)
 			"(mii_bus:phy_addr=%s, id=%x)\n",
 			priv->phydev->drv->name, dev_name(&priv->phydev->dev),
 			priv->phydev->phy_id);
-	} else {
+	}
+
+	if (!priv->phydev) {
 		/* No PHY , fix the link, speed and duplex settings */
 		dev_notice(emac_dev, "no phy, defaulting to 100/full\n");
 		priv->link = 1;
-- 
2.1.4

  parent reply	other threads:[~2015-01-13 19:33 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-13 19:29 [PATCH 0/6] Fixes for davinci_emac Tony Lindgren
2015-01-13 19:29 ` [PATCH 1/6] net: davinci_emac: Fix hangs with interrupts Tony Lindgren
2015-01-13 19:36   ` Felipe Balbi
2015-01-13 19:45     ` Tony Lindgren
2015-01-13 19:29 ` [PATCH 2/6] net: davinci_emac: Fix runtime pm calls for davinci_emac Tony Lindgren
2015-01-13 19:51   ` Felipe Balbi
2015-01-13 20:54     ` Tony Lindgren
2015-01-13 21:03       ` Felipe Balbi
2015-01-13 23:42       ` Mark A. Greer
2015-01-13 19:29 ` [PATCH 3/6] net: davinci_emac: Free clock after checking the frequency Tony Lindgren
2015-01-13 19:48   ` Tom Lendacky
2015-01-13 19:50     ` Felipe Balbi
2015-01-13 20:15       ` Tony Lindgren
2015-01-13 19:54     ` Tony Lindgren
2015-01-13 21:05       ` David Miller
2015-01-14 19:10         ` Tony Lindgren
2015-01-13 19:29 ` Tony Lindgren [this message]
2015-01-13 19:29 ` [PATCH 5/6] net: davinci_emac: Fix ioremap for devices with MDIO within the EMAC address space Tony Lindgren
2015-01-13 19:54   ` Felipe Balbi
2015-01-13 19:59     ` Tony Lindgren
2015-01-13 20:21       ` Felipe Balbi
2015-01-13 19:29 ` [PATCH 6/6] net: davinci_emac: Add support for emac on dm816x Tony Lindgren
  -- strict thread matches above, loose matches on Subject: below --
2015-01-15 22:45 [PATCHv2 0/6] Fixes for davinci_emac Tony Lindgren
2015-01-15 22:45 ` [PATCH 4/6] net: davinci_emac: Fix incomplete code for getting the phy from device tree Tony Lindgren

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=1421177368-19756-5-git-send-email-tony@atomide.com \
    --to=tony@atomide.com \
    --cc=b.hutchman@gmail.com \
    --cc=balbi@ti.com \
    --cc=davem@davemloft.net \
    --cc=linux-omap@vger.kernel.org \
    --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).