mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] net: take eth id from devicetree alias
@ 2014-05-15  8:05 Sascha Hauer
  0 siblings, 0 replies; only message in thread
From: Sascha Hauer @ 2014-05-15  8:05 UTC (permalink / raw)
  To: barebox

If the devicetree has an alias for the ethernet device, then use
it.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 net/eth.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/net/eth.c b/net/eth.c
index 26a5ff7..b830f79 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -330,12 +330,21 @@ int eth_register(struct eth_device *edev)
 	}
 
 	strcpy(edev->dev.name, "eth");
-	edev->dev.id = DEVICE_ID_DYNAMIC;
 
 	if (edev->parent)
 		edev->dev.parent = edev->parent;
 
-	register_device(&edev->dev);
+	if (edev->dev.parent && edev->dev.parent->device_node) {
+		edev->dev.id = of_alias_get_id(edev->dev.parent->device_node, "ethernet");
+		if (edev->dev.id < 0)
+			edev->dev.id = DEVICE_ID_DYNAMIC;
+	} else {
+		edev->dev.id = DEVICE_ID_DYNAMIC;
+	}
+
+	ret = register_device(&edev->dev);
+	if (ret)
+		return ret;
 
 	dev_add_param_ip(dev, "ipaddr", NULL, NULL, &edev->ipaddr, edev);
 	dev_add_param_ip(dev, "serverip", NULL, NULL, &edev->serverip, edev);
-- 
2.0.0.rc0


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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2014-05-15  8:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-15  8:05 [PATCH] net: take eth id from devicetree alias Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox