[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20230414212356.9326-3-zajec5@gmail.com>
Date: Fri, 14 Apr 2023 23:23:56 +0200
From: Rafał Miłecki <zajec5@...il.com>
To: Kalle Valo <kvalo@...nel.org>, Rob Herring <robh+dt@...nel.org>,
Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>
Cc: "David S . Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, ath11k@...ts.infradead.org,
linux-wireless@...r.kernel.org, netdev@...r.kernel.org,
devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
Robert Marko <robimarko@...il.com>,
Rafał Miłecki <rafal@...ecki.pl>
Subject: [PATCH 3/3] wifi: ath11k: support reading radio MAC from DT
From: Rafał Miłecki <rafal@...ecki.pl>
On some devices (most routers) MAC is stored in an NVMEM cell. Support
reading it.
Signed-off-by: Rafał Miłecki <rafal@...ecki.pl>
---
drivers/net/wireless/ath/ath11k/mac.c | 15 ++++++++++-----
1 file changed, 10 insertions(+), 5 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index ad5a22d12bd3..6550bb5b2ece 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -8,6 +8,7 @@
#include <linux/etherdevice.h>
#include <linux/bitfield.h>
#include <linux/inetdevice.h>
+#include <linux/of_net.h>
#include <net/if_inet6.h>
#include <net/ipv6.h>
@@ -9292,7 +9293,7 @@ int ath11k_mac_register(struct ath11k_base *ab)
struct ath11k_pdev *pdev;
int i;
int ret;
- u8 mac_addr[ETH_ALEN] = {0};
+ u8 device_mac_addr[ETH_ALEN] = {0};
if (test_bit(ATH11K_FLAG_REGISTERED, &ab->dev_flags))
return 0;
@@ -9305,18 +9306,22 @@ int ath11k_mac_register(struct ath11k_base *ab)
if (ret)
return ret;
- device_get_mac_address(ab->dev, mac_addr);
+ device_get_mac_address(ab->dev, device_mac_addr);
for (i = 0; i < ab->num_radios; i++) {
+ u8 radio_mac_addr[ETH_ALEN];
+
pdev = &ab->pdevs[i];
ar = pdev->ar;
- if (ab->pdevs_macaddr_valid) {
+ if (!of_get_mac_address(ar->np, radio_mac_addr)) {
+ ether_addr_copy(ar->mac_addr, radio_mac_addr);
+ } else if (ab->pdevs_macaddr_valid) {
ether_addr_copy(ar->mac_addr, pdev->mac_addr);
} else {
- if (is_zero_ether_addr(mac_addr))
+ if (is_zero_ether_addr(device_mac_addr))
ether_addr_copy(ar->mac_addr, ab->mac_addr);
else
- ether_addr_copy(ar->mac_addr, mac_addr);
+ ether_addr_copy(ar->mac_addr, device_mac_addr);
ar->mac_addr[4] += i;
}
--
2.34.1
Powered by blists - more mailing lists