mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Sascha Hauer <s.hauer@pengutronix.de>
To: Barebox List <barebox@lists.infradead.org>
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] net: bcmgenet: Fix MAC address setting
Date: Fri,  2 Dec 2022 11:52:04 +0100	[thread overview]
Message-ID: <20221202105204.3076891-1-s.hauer@pengutronix.de> (raw)

bcmgenet_set_hwaddr() only copies the MAC address only into internal
state, but not into hardware. Copying to hardware is done in
__bcmgenet_set_hwaddr() called during open time. Depending on
nv.dev.eth0.ethaddr being set the order in which both functions
are called changes.

Copy the state into hardware as well in bcmgenet_set_hwaddr(). This
fixes sending packets when nv.dev.eth0.ethaddr is not set.

Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
 drivers/net/bcmgenet.c | 20 +++++++++++---------
 1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/drivers/net/bcmgenet.c b/drivers/net/bcmgenet.c
index 79514dfa69..8df5fd5dea 100644
--- a/drivers/net/bcmgenet.c
+++ b/drivers/net/bcmgenet.c
@@ -215,15 +215,6 @@ static void bcmgenet_umac_reset(struct bcmgenet_eth_priv *priv)
 	writel(1, (priv->mac_reg + RBUF_TBUF_SIZE_CTRL));
 }
 
-static int bcmgenet_set_hwaddr(struct eth_device *dev, const unsigned char *addr)
-{
-	struct bcmgenet_eth_priv *priv = dev->priv;
-
-	memcpy(priv->addr, addr, 6);
-
-	return 0;
-}
-
 static int __bcmgenet_set_hwaddr(struct bcmgenet_eth_priv *priv)
 {
 	const unsigned char *addr = priv->addr;
@@ -238,6 +229,17 @@ static int __bcmgenet_set_hwaddr(struct bcmgenet_eth_priv *priv)
 	return 0;
 }
 
+static int bcmgenet_set_hwaddr(struct eth_device *dev, const unsigned char *addr)
+{
+	struct bcmgenet_eth_priv *priv = dev->priv;
+
+	memcpy(priv->addr, addr, 6);
+
+	__bcmgenet_set_hwaddr(priv);
+
+	return 0;
+}
+
 static int bcmgenet_get_hwaddr(struct eth_device *edev, unsigned char *mac)
 {
 	return -1;
-- 
2.30.2




                 reply	other threads:[~2022-12-02 10:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20221202105204.3076891-1-s.hauer@pengutronix.de \
    --to=s.hauer@pengutronix.de \
    --cc=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