netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC net-next/wireless-next v1 1/2] ethernet: check nvmem cells for mac-address
@ 2021-10-30 17:41 Christian Lamparter
  2021-10-30 17:41 ` [RFC net-next/wireless-next v1 2/2] ath10k: move device_get_mac_address() and pass errors up the chain Christian Lamparter
  0 siblings, 1 reply; 4+ messages in thread
From: Christian Lamparter @ 2021-10-30 17:41 UTC (permalink / raw)
  To: netdev, linux-acpi, linux-wireless, ath10k
  Cc: Ansuel Smith, Kalle Valo, David S . Miller, Rafael J . Wysocki,
	Jakub Kicinski, Len Brown, Andrew Lunn, Michael Walle,
	Arnd Bergmann

of_get_mac_address() gained this function with
commit d01f449c008a ("of_net: add NVMEM support to of_get_mac_address")
with the following justification:
"Many embedded devices have information such as MAC addresses stored
inside NVMEMs like EEPROMs and so on. [...]

Adding support for NVMEM into every other driver would mean adding a lot
of repetitive code. This patch allows us to configure MAC addresses in
various devices like ethernet and wireless adapters directly [...]."

the common device_/fwnode_get_mac_address could use the
same functionality by just a few adjustments.

Signed-off-by: Christian Lamparter <chunkeey@gmail.com>
---
 net/ethernet/eth.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ethernet/eth.c b/net/ethernet/eth.c
index c7d9e08107cb..5e55b08577b1 100644
--- a/net/ethernet/eth.c
+++ b/net/ethernet/eth.c
@@ -602,7 +602,9 @@ static int fwnode_get_mac_addr(struct fwnode_handle *fwnode,
  * checked first, because that is supposed to contain to "most recent" MAC
  * address. If that isn't set, then 'local-mac-address' is checked next,
  * because that is the default address.  If that isn't set, then the obsolete
- * 'address' is checked, just in case we're using an old device tree.
+ * 'address' is checked, just in case we're using an old device tree. If any
+ * of the above isn't set, then try to get MAC address from nvmem cell named
+ * 'mac-address'.
  *
  * Note that the 'address' property is supposed to contain a virtual address of
  * the register set, but some DTS files have redefined that property to be the
@@ -622,7 +624,7 @@ int fwnode_get_mac_address(struct fwnode_handle *fwnode, char *addr)
 	    !fwnode_get_mac_addr(fwnode, "address", addr))
 		return 0;
 
-	return -ENOENT;
+	return nvmem_get_mac_address(fwnode->dev, addr);
 }
 EXPORT_SYMBOL(fwnode_get_mac_address);
 
-- 
2.33.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-11-04 15:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-10-30 17:41 [RFC net-next/wireless-next v1 1/2] ethernet: check nvmem cells for mac-address Christian Lamparter
2021-10-30 17:41 ` [RFC net-next/wireless-next v1 2/2] ath10k: move device_get_mac_address() and pass errors up the chain Christian Lamparter
2021-11-02 22:08   ` Mathias Kresin
2021-11-04 15:51     ` Christian Lamparter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).