All of lore.kernel.org
 help / color / mirror / Atom feed
From: Rosen Penev <rosenp@gmail.com>
To: netdev@vger.kernel.org
Cc: "David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	"Jakub Kicinski" <kuba@kernel.org>,
	"Paolo Abeni" <pabeni@redhat.com>,
	"Rosen Penev" <rosenp@gmail.com>, "Andrew Lunn" <andrew@lunn.ch>,
	"Simon Horman" <horms@kernel.org>,
	"Uwe Kleine-König" <u.kleine-koenig@baylibre.com>,
	"Breno Leitao" <leitao@debian.org>,
	"Jeff Johnson" <quic_jjohnson@quicinc.com>,
	"Christian Marangi" <ansuelsmth@gmail.com>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCHv5 net-next 6/7] net: ibm: emac: generate random MAC if not found
Date: Thu, 10 Oct 2024 10:44:23 -0700	[thread overview]
Message-ID: <20241010174424.7310-7-rosenp@gmail.com> (raw)
In-Reply-To: <20241010174424.7310-1-rosenp@gmail.com>

On this Cisco MX60W, u-boot sets the local-mac-address property.
Unfortunately by default, the MAC is wrong and is actually located on a
UBI partition. Which means nvmem needs to be used to grab it.

In the case where that fails, EMAC fails to initialize instead of
generating a random MAC as many other drivers do.

Match behavior with other drivers to have a working ethernet interface.

Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
 drivers/net/ethernet/ibm/emac/core.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/ibm/emac/core.c b/drivers/net/ethernet/ibm/emac/core.c
index b9ccaae61c48..faa483790b29 100644
--- a/drivers/net/ethernet/ibm/emac/core.c
+++ b/drivers/net/ethernet/ibm/emac/core.c
@@ -2937,9 +2937,12 @@ static int emac_init_config(struct emac_instance *dev)
 
 	/* Read MAC-address */
 	err = of_get_ethdev_address(np, dev->ndev);
-	if (err)
-		return dev_err_probe(&dev->ofdev->dev, err,
-				     "Can't get valid [local-]mac-address from OF !\n");
+	if (err == -EPROBE_DEFER)
+		return err;
+	if (err) {
+		dev_warn(&dev->ofdev->dev, "Can't get valid mac-address. Generating random.");
+		eth_hw_addr_random(dev->ndev);
+	}
 
 	/* IAHT and GAHT filter parameterization */
 	if (emac_has_feature(dev, EMAC_FTR_EMAC4SYNC)) {
-- 
2.46.2


  parent reply	other threads:[~2024-10-10 17:44 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-10 17:44 [PATCHv5 net-next 0/7] ibm: emac: more cleanups Rosen Penev
2024-10-10 17:44 ` [PATCHv5 net-next 1/7] net: ibm: emac: use netif_receive_skb_list Rosen Penev
2024-10-10 17:44 ` [PATCHv5 net-next 2/7] net: ibm: emac: remove custom init/exit functions Rosen Penev
2024-10-10 17:44 ` [PATCHv5 net-next 3/7] net: ibm: emac: use devm_platform_ioremap_resource Rosen Penev
2024-10-10 17:44 ` [PATCHv5 net-next 4/7] net: ibm: emac: use platform_get_irq Rosen Penev
2024-10-10 17:44 ` [PATCHv5 net-next 5/7] net: ibm: emac: use devm for mutex_init Rosen Penev
2024-10-10 17:44 ` Rosen Penev [this message]
2024-10-10 17:44 ` [PATCHv5 net-next 7/7] net: ibm: emac: use of_find_matching_node Rosen Penev
2024-10-10 20:40 ` [PATCHv5 net-next 0/7] ibm: emac: more cleanups Jakub Kicinski

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=20241010174424.7310-7-rosenp@gmail.com \
    --to=rosenp@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=ansuelsmth@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=quic_jjohnson@quicinc.com \
    --cc=u.kleine-koenig@baylibre.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.