summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRenaud Barbier <renaud.barbier@ge.com>2013-09-04 08:37:03 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2013-09-05 10:28:04 +0200
commita78431c7fc42193be252417bf06f7cc61765a51e (patch)
treeb68364d9bd36de42bd5f5e1563f2070cf0356978
parentda19582070da7918c901c26d001c6d0114291461 (diff)
downloadbarebox-a78431c7fc42193be252417bf06f7cc61765a51e.tar.gz
barebox-a78431c7fc42193be252417bf06f7cc61765a51e.tar.xz
net, of: fixup MAC address by alias
If a network device has not been registered from the devicetree, we may still find it by its alias in the devicetree. This way also platform based network devices can obtain a valid MAC address in the devicetree. Signed-off-by: Renaud Barbier <renaud.barbier@ge.com> Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--net/eth.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/net/eth.c b/net/eth.c
index e94689ad8a..e5d6a35822 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -273,7 +273,7 @@ static int eth_set_ethaddr(struct device_d *dev, struct param_d *param, const ch
return 0;
}
-#ifdef CONFIG_OFDEVICE
+#ifdef CONFIG_OFTREE
static int eth_of_fixup(struct device_node *root)
{
struct eth_device *edev;
@@ -285,21 +285,23 @@ static int eth_of_fixup(struct device_node *root)
* find a nodepath for and which has a valid mac address.
*/
list_for_each_entry(edev, &netdev_list, list) {
- if (!edev->nodepath) {
- dev_dbg(&edev->dev, "%s: no node to fixup\n", __func__);
+ if (!is_valid_ether_addr(edev->ethaddr)) {
+ dev_dbg(&edev->dev,
+ "%s: no valid mac address, cannot fixup\n",
+ __func__);
continue;
}
- if (!is_valid_ether_addr(edev->ethaddr)) {
- dev_dbg(&edev->dev, "%s: no valid mac address, cannot fixup\n",
- __func__);
- continue;
+ if (edev->nodepath) {
+ node = of_find_node_by_path_from(root, edev->nodepath);
+ } else {
+ char eth[12];
+ sprintf(eth, "ethernet%d", edev->dev.id);
+ node = of_find_node_by_alias(root, eth);
}
- node = of_find_node_by_path_from(root, edev->nodepath);
if (!node) {
- dev_dbg(&edev->dev, "%s: fixup node %s not found\n",
- __func__, edev->nodepath);
+ dev_dbg(&edev->dev, "%s: no node to fixup\n", __func__);
continue;
}