[PATCH] net: take eth id from devicetree alias

Sascha Hauer s.hauer at pengutronix.de
Thu May 15 01:05:23 PDT 2014


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

Signed-off-by: Sascha Hauer <s.hauer at 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




More information about the barebox mailing list