9
0
Fork 0

net: take eth id from devicetree alias

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

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
This commit is contained in:
Sascha Hauer 2014-05-15 09:56:35 +02:00
parent 0ca1d8a456
commit 0cf4630cd2
1 changed files with 11 additions and 2 deletions

View File

@ -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);