1 From: David Bauer <mail@david-bauer.net>
2 Date: Tue, 20 Jul 2021 22:00:10 +0200
3 Subject: [PATCH] generic: add mac-address property for NVMEM mac addresses
5 Traversing the device-tree by referencing a network device to determine
6 a devices labe-mac does not work with the generic nvmem implementation,
7 as the userspace expects the MAC-address to be available as a
10 The legacy mtd-mac-address implementation did create such a node. Do the
11 same when using the nvmem implementation to allow reading the MAC
14 Fixes commit d284e6ef0f06 ("treewide: convert mtd-mac-address-increment*
15 to generic implementation")
17 Signed-off-by: David Bauer <mail@david-bauer.net>
19 --- a/drivers/of/of_net.c
20 +++ b/drivers/of/of_net.c
21 @@ -61,6 +61,7 @@ static void *of_get_mac_addr_nvmem(struc
23 u8 nvmem_mac[ETH_ALEN];
24 struct platform_device *pdev = of_find_device_by_node(np);
25 + struct property *prop;
29 @@ -78,10 +79,29 @@ static void *of_get_mac_addr_nvmem(struc
30 put_device(&pdev->dev);
37 + prop = devm_kzalloc(&pdev->dev, sizeof(*prop), GFP_KERNEL);
42 + prop->name = "mac-address";
43 + prop->length = ETH_ALEN;
44 + prop->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
45 + if (!prop->value || of_add_property(np, prop)) {
53 + devm_kfree(&pdev->dev, prop->value);
54 + devm_kfree(&pdev->dev, prop);
55 + devm_kfree(&pdev->dev, mac);
59 static void *of_get_mac_address_mtd(struct device_node *np)