summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2015-11-06 16:10:44 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2015-11-06 16:10:44 +0100
commit6aed170ef1ce8004972dc28e98204cd148d28631 (patch)
tree0914012010c17be3560d3b0bd16ef5d81fc33015
parentb5c7b09c8a4c089c644fd713924e733a1eebff69 (diff)
parent9956226fbbc6fda84dcd5298723ad4827b037c58 (diff)
downloadbarebox-6aed170ef1ce8004972dc28e98204cd148d28631.tar.gz
barebox-6aed170ef1ce8004972dc28e98204cd148d28631.tar.xz
Merge branch 'for-next/net'
-rw-r--r--drivers/net/phy/phy.c13
-rw-r--r--net/eth.c72
2 files changed, 51 insertions, 34 deletions
diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c
index 2b3c5e2e02..25c999c550 100644
--- a/drivers/net/phy/phy.c
+++ b/drivers/net/phy/phy.c
@@ -502,13 +502,16 @@ int phy_wait_aneg_done(struct phy_device *phydev)
return 0;
while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND)) {
- if (phy_aneg_done(phydev) > 0) {
- phydev->link = 1;
- return 0;
- }
+ if (phy_aneg_done(phydev) > 0)
+ break;
}
- phydev->link = 0;
+ do {
+ genphy_update_link(phydev);
+ if (phydev->link == 1)
+ return 0;
+ } while (!is_timeout(start, PHY_AN_TIMEOUT * SECOND));
+
return -ETIMEDOUT;
}
diff --git a/net/eth.c b/net/eth.c
index b22e55668a..8bfb6b10a7 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -289,43 +289,57 @@ static int eth_param_set_ethaddr(struct param_d *param, void *priv)
}
#ifdef CONFIG_OFTREE
-static int eth_of_fixup(struct device_node *root, void *unused)
+static void eth_of_fixup_node(struct device_node *root,
+ const char *node_path, int ethid,
+ const u8 ethaddr[6])
{
- struct eth_device *edev;
struct device_node *node;
int ret;
- /*
- * Add the mac-address property for each network device we
- * find a nodepath for and which has a valid mac address.
- */
- list_for_each_entry(edev, &netdev_list, list) {
- 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);
- }
+ if (!is_valid_ether_addr(ethaddr)) {
+ pr_debug("%s: no valid mac address, cannot fixup\n",
+ __func__);
+ return;
+ }
- if (!node) {
- dev_dbg(&edev->dev, "%s: no node to fixup\n", __func__);
- continue;
- }
+ if (node_path) {
+ node = of_find_node_by_path_from(root, node_path);
+ } else {
+ char eth[12];
+ sprintf(eth, "ethernet%d", ethid);
+ node = of_find_node_by_alias(root, eth);
+ }
- ret = of_set_property(node, "mac-address", edev->ethaddr, 6, 1);
- if (ret)
- pr_err("Setting mac-address property of %s failed with: %s\n",
- node->full_name, strerror(-ret));
+ if (!node) {
+ pr_debug("%s: no node to fixup\n", __func__);
+ return;
}
+ ret = of_set_property(node, "mac-address", ethaddr, 6, 1);
+ if (ret)
+ pr_err("Setting mac-address property of %s failed with: %s\n",
+ node->full_name, strerror(-ret));
+}
+
+static int eth_of_fixup(struct device_node *root, void *unused)
+{
+ struct eth_ethaddr *addr;
+ struct eth_device *edev;
+
+ /*
+ * Add the mac-address property for each ethaddr and then each network
+ * device we find a node path for and which has a valid mac address.
+ * This will find both network devices barebox was told about as well as
+ * addresses registered by boards but for which no network device was
+ * ever loaded.
+ */
+ list_for_each_entry(addr, &ethaddr_list, list)
+ eth_of_fixup_node(root, addr->node ? addr->node->full_name : NULL,
+ addr->ethid, addr->ethaddr);
+
+ list_for_each_entry(edev, &netdev_list, list)
+ eth_of_fixup_node(root, edev->nodepath, edev->dev.id, edev->ethaddr);
+
return 0;
}