[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20241220-net-mac-nvmem-offset-v1-2-e9d1da2c1681@linaro.org>
Date: Fri, 20 Dec 2024 20:17:07 +0100
From: Linus Walleij <linus.walleij@...aro.org>
To: Andrew Lunn <andrew+netdev@...n.ch>,
"David S. Miller" <davem@...emloft.net>, Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Rob Herring <robh@...nel.org>, Krzysztof Kozlowski <krzk+dt@...nel.org>,
Conor Dooley <conor+dt@...nel.org>, Andrew Lunn <andrew@...n.ch>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>, Simon Horman <horms@...nel.org>
Cc: netdev@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, Linus Walleij <linus.walleij@...aro.org>
Subject: [PATCH 2/2] net: of: Support adding offset to nvmem MAC addresses
If a lower-byte MAC address offset is encoded into the device
tree, make sure to add this to the returned address when
looking up a MAC address from NVMEM.
Signed-off-by: Linus Walleij <linus.walleij@...aro.org>
---
net/core/of_net.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/net/core/of_net.c b/net/core/of_net.c
index 93ea425b9248a23f4f95a336e9cdbf0053248e32..c98000ec13377ea4b541e182a66be8b1010edc40 100644
--- a/net/core/of_net.c
+++ b/net/core/of_net.c
@@ -64,6 +64,7 @@ int of_get_mac_address_nvmem(struct device_node *np, u8 *addr)
struct nvmem_cell *cell;
const void *mac;
size_t len;
+ u32 offset;
int ret;
/* Try lookup by device first, there might be a nvmem_cell_lookup
@@ -72,7 +73,7 @@ int of_get_mac_address_nvmem(struct device_node *np, u8 *addr)
if (pdev) {
ret = nvmem_get_mac_address(&pdev->dev, addr);
put_device(&pdev->dev);
- return ret;
+ goto add_offset_exit;
}
cell = of_nvmem_cell_get(np, "mac-address");
@@ -92,8 +93,13 @@ int of_get_mac_address_nvmem(struct device_node *np, u8 *addr)
memcpy(addr, mac, ETH_ALEN);
kfree(mac);
+ ret = 0;
- return 0;
+add_offset_exit:
+ if (!ret && !of_property_read_u32(np, "nvmem-mac-minor-offset", &offset))
+ addr[ETH_ALEN - 1] += offset;
+
+ return ret;
}
EXPORT_SYMBOL(of_get_mac_address_nvmem);
--
2.47.1
Powered by blists - more mailing lists