[PATCH 2/4] net: factor out eth_of_get_fixup_node
Ahmad Fatoum
a.fatoum at pengutronix.de
Tue Nov 26 07:17:42 PST 2024
We only know at fixup time, which MAC addresses were actually assigned
to interfaces. Factor out eth_of_get_fixup_node from the MAC address
assignment code, so board code can use this to retrace which MAC
addresses would be fixed up.
Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
include/net.h | 12 ++++++++++++
net/eth.c | 29 +++++++++++++++++++----------
2 files changed, 31 insertions(+), 10 deletions(-)
diff --git a/include/net.h b/include/net.h
index 1b6995b50043..4d4996c720ef 100644
--- a/include/net.h
+++ b/include/net.h
@@ -128,6 +128,18 @@ static inline void of_eth_register_ethaddr(struct device_node *node,
void eth_register_ethaddr(int ethid, const char *ethaddr);
void of_eth_register_ethaddr(struct device_node *node, const char *ethaddr);
#endif
+
+#ifdef CONFIG_OFTREE
+struct device_node *eth_of_get_fixup_node(struct device_node *root,
+ const char *node_path, int ethid);
+#else
+static inline struct device_node *eth_of_get_fixup_node(struct device_node *root,
+ const char *node_path, int ethid)
+{
+ return NULL;
+}
+#endif
+
/*
* Ethernet header
*/
diff --git a/net/eth.c b/net/eth.c
index 7229530c055b..a1d6860be830 100644
--- a/net/eth.c
+++ b/net/eth.c
@@ -319,19 +319,11 @@ static int eth_param_set_ethaddr(struct param_d *param, void *priv)
}
#ifdef CONFIG_OFTREE
-static void eth_of_fixup_node(struct device_node *root,
- const char *node_path, int ethid,
- const u8 ethaddr[ETH_ALEN])
+struct device_node *eth_of_get_fixup_node(struct device_node *root,
+ const char *node_path, int ethid)
{
struct device_node *bb_node, *fixup_node;
char *name;
- int ret;
-
- if (!is_valid_ether_addr(ethaddr)) {
- pr_debug("%s: no valid mac address, cannot fixup\n",
- __func__);
- return;
- }
if (node_path) {
bb_node = of_find_node_by_path_from(0, node_path);
@@ -344,6 +336,23 @@ static void eth_of_fixup_node(struct device_node *root,
fixup_node = of_find_node_by_alias(root, eth);
}
+ return fixup_node;
+}
+
+static void eth_of_fixup_node(struct device_node *root,
+ const char *node_path, int ethid,
+ const u8 ethaddr[ETH_ALEN])
+{
+ struct device_node *fixup_node;
+ int ret;
+
+ if (!is_valid_ether_addr(ethaddr)) {
+ pr_debug("%s: no valid mac address, cannot fixup\n",
+ __func__);
+ return;
+ }
+
+ fixup_node = eth_of_get_fixup_node(root, node_path, ethid);
if (!fixup_node) {
pr_debug("%s: no node to fixup\n", __func__);
return;
--
2.39.5
More information about the barebox
mailing list