[PATCH] wifi: ath11k: support fetching mac address from nvmem

George Moussalem via B4 Relay posted 1 patch 8 months, 4 weeks ago
drivers/net/wireless/ath/ath11k/mac.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
[PATCH] wifi: ath11k: support fetching mac address from nvmem
Posted by George Moussalem via B4 Relay 8 months, 4 weeks ago
From: George Moussalem <george.moussalem@outlook.com>

Many embedded devices with ath11k wifi chips store their mac address in
nvmem partitions. Currently, the ath11k driver supports getting the
mac address from the 'mac-address', 'local-mac-address', and 'address'
device tree properties only. As such, add support for obtaining the mac
address from nvmem if defined in a 'mac-address' cell by replacing the
call to device_get_mac_address by of_get_mac_address which does exactly
the same as the former but tries to get it from nvmem if it is not set
by above mentioned DT properties,

Tested-on: IPQ5018, QCN6122, and QCN9074

Signed-off-by: George Moussalem <george.moussalem@outlook.com>
---
 drivers/net/wireless/ath/ath11k/mac.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
index 97816916abac..49af6b9fc867 100644
--- a/drivers/net/wireless/ath/ath11k/mac.c
+++ b/drivers/net/wireless/ath/ath11k/mac.c
@@ -9,6 +9,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>
 
@@ -10379,7 +10380,7 @@ int ath11k_mac_register(struct ath11k_base *ab)
 	if (ret)
 		return ret;
 
-	device_get_mac_address(ab->dev, mac_addr);
+	of_get_mac_address(ab->dev->of_node, mac_addr);
 
 	for (i = 0; i < ab->num_radios; i++) {
 		pdev = &ab->pdevs[i];

---
base-commit: 9388ec571cb1adba59d1cded2300eeb11827679c
change-id: 20250324-ath11k-nvmem-9b4f54f44188

Best regards,
-- 
George Moussalem <george.moussalem@outlook.com>
Re: [PATCH] wifi: ath11k: support fetching mac address from nvmem
Posted by Vasanthakumar Thiagarajan 6 months, 1 week ago

On 3/24/2025 11:54 AM, George Moussalem via B4 Relay wrote:
> From: George Moussalem <george.moussalem@outlook.com>
> 
> Many embedded devices with ath11k wifi chips store their mac address in
> nvmem partitions. Currently, the ath11k driver supports getting the
> mac address from the 'mac-address', 'local-mac-address', and 'address'
> device tree properties only. As such, add support for obtaining the mac
> address from nvmem if defined in a 'mac-address' cell by replacing the
> call to device_get_mac_address by of_get_mac_address which does exactly
> the same as the former but tries to get it from nvmem if it is not set
> by above mentioned DT properties,

May be not exactly, this also moves from a generic API to DT specific API that
might impact systems which dont have device tree (x86)?

> 
> Tested-on: IPQ5018, QCN6122, and QCN9074

You may want to follow the existing Tested-on style.

> 
> Signed-off-by: George Moussalem <george.moussalem@outlook.com>
> ---
>   drivers/net/wireless/ath/ath11k/mac.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/ath/ath11k/mac.c b/drivers/net/wireless/ath/ath11k/mac.c
> index 97816916abac..49af6b9fc867 100644
> --- a/drivers/net/wireless/ath/ath11k/mac.c
> +++ b/drivers/net/wireless/ath/ath11k/mac.c
> @@ -9,6 +9,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>
>   
> @@ -10379,7 +10380,7 @@ int ath11k_mac_register(struct ath11k_base *ab)
>   	if (ret)
>   		return ret;
>   
> -	device_get_mac_address(ab->dev, mac_addr);
> +	of_get_mac_address(ab->dev->of_node, mac_addr);

May be call of_get_mac_address_nvmem() when device_get_mac_address() fails?

Vasanth