generic: write back netdev MAC-address to device-tree

The label-mac logic relies on the mac-address property of a netdev
devices of-node. However, the mac address can also be stored as a
different property or read from e.g. an mtd device.

Create this node when reading a mac-address from OF if it does not
already exist and copy the mac-address used for the device to this
property. This way, the MAC address can be accessed using procfs.

Signed-off-by: David Bauer <mail@david-bauer.net>
This commit is contained in:
David Bauer
2021-07-29 00:29:53 +02:00
parent 57ece63cd8
commit cd39aba402
6 changed files with 112 additions and 54 deletions

View File

@@ -64,10 +64,10 @@ Signed-off-by: Ansuel Smith <ansuelsmth@gmail.com>
+static void *of_get_mac_address_mtd(struct device_node *np)
{
#ifdef CONFIG_MTD
struct device_node *mtd_np = NULL;
@@ -167,28 +172,54 @@ free:
struct platform_device *pdev = of_find_device_by_node(np);
@@ -152,28 +157,54 @@ static const void *of_get_mac_address_mt
* If a mtd-mac-address property exists, try to fetch the MAC address from the
* specified mtd device, and store it as a 'mac-address' property
* specified mtd device.
*
+ * DT can tell the system to increment the mac-address after is extracted by
+ * using: