[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211030174111.1432663-1-chunkeey@gmail.com>
Date: Sat, 30 Oct 2021 19:41:10 +0200
From: Christian Lamparter <chunkeey@...il.com>
To: netdev@...r.kernel.org, linux-acpi@...r.kernel.org,
linux-wireless@...r.kernel.org, ath10k@...ts.infradead.org
Cc: Ansuel Smith <ansuelsmth@...il.com>,
Kalle Valo <kvalo@...eaurora.org>,
"David S . Miller" <davem@...emloft.net>,
"Rafael J . Wysocki" <rafael@...nel.org>,
Jakub Kicinski <kuba@...nel.org>, Len Brown <lenb@...nel.org>,
Andrew Lunn <andrew@...n.ch>, Michael Walle <michael@...le.cc>,
Arnd Bergmann <arnd@...db.de>
Subject: [RFC net-next/wireless-next v1 1/2] ethernet: check nvmem cells for mac-address
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@...il.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
Powered by blists - more mailing lists