mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH] net: cpsw: ignore error on slave setup
Date: Tue,  6 Jan 2015 15:11:20 +0100	[thread overview]
Message-ID: <1420553480-18235-1-git-send-email-s.hauer@pengutronix.de> (raw)

The CPSW has two slaves. When one of them fails to setup continue
anyway with the other one. This fixes a crash in the beaglebone black
which only has one slave connected. The code doesn't find a phy on
the second slave and bails out, but the error path is broken: It frees
the private data structures which contains used resources.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/cpsw.c | 29 ++++++++++++++---------------
 1 file changed, 14 insertions(+), 15 deletions(-)

diff --git a/drivers/net/cpsw.c b/drivers/net/cpsw.c
index b6618ad..799fac8 100644
--- a/drivers/net/cpsw.c
+++ b/drivers/net/cpsw.c
@@ -910,6 +910,16 @@ static int cpsw_slave_setup(struct cpsw_slave *slave, int slave_num,
 	struct eth_device	*edev = &slave->edev;
 	struct device_d		*dev = &slave->dev;
 	int ret;
+	struct phy_device *phy;
+
+	phy = mdiobus_scan(&priv->miibus, priv->slaves[slave_num].phy_id);
+	if (IS_ERR(phy))
+		return PTR_ERR(phy);
+
+	phy->dev.device_node = priv->slaves[slave_num].dev.device_node;
+	ret = phy_register_device(phy);
+	if (ret)
+		return ret;
 
 	sprintf(dev->name, "cpsw-slave");
 	dev->id = slave->slave_num;
@@ -1199,22 +1209,11 @@ int cpsw_probe(struct device_d *dev)
 	mdiobus_register(&priv->miibus);
 
 	for (i = 0; i < priv->num_slaves; i++) {
-		struct phy_device *phy;
-
-		phy = mdiobus_scan(&priv->miibus, priv->slaves[i].phy_id);
-		if (IS_ERR(phy)) {
-			ret = PTR_ERR(phy);
-			goto out;
-		}
-
-		phy->dev.device_node = priv->slaves[i].dev.device_node;
-		ret = phy_register_device(phy);
-		if (ret)
-			goto out;
-
 		ret = cpsw_slave_setup(&priv->slaves[i], i, priv);
-		if (ret)
-			goto out;
+		if (ret) {
+			dev_err(dev, "Failed to setup slave %d: %s\n", i, strerror(-ret));
+			continue;
+		}
 	}
 
 	return 0;
-- 
2.1.4


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

                 reply	other threads:[~2015-01-06 14:11 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=1420553480-18235-1-git-send-email-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=barebox@lists.infradead.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