mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 2/4] net: factor out eth_of_get_fixup_node
Date: Tue, 26 Nov 2024 16:17:42 +0100	[thread overview]
Message-ID: <20241126151744.3621717-3-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20241126151744.3621717-1-a.fatoum@pengutronix.de>

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




  parent reply	other threads:[~2024-11-26 15:18 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-26 15:17 [PATCH 0/4] net: ethernet address helpers for board code Ahmad Fatoum
2024-11-26 15:17 ` [PATCH 1/4] net: add ethaddr sequence handling Ahmad Fatoum
2024-11-26 15:17 ` Ahmad Fatoum [this message]
2024-11-26 15:17 ` [PATCH 3/4] net: export list of registered ethernet addresses Ahmad Fatoum
2024-11-26 15:17 ` [PATCH 4/4] net: implement ethaddr_string_cmp() Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20241126151744.3621717-3-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox