[openwrt/openwrt] Revert "generic: add mac-address property for NVMEM mac addresses"

LEDE Commits lede-commits at lists.infradead.org
Wed Jul 28 04:48:11 PDT 2021


blocktrron pushed a commit to openwrt/openwrt.git, branch master:
https://git.openwrt.org/bd521f2a832ef1b4ea1a7680c0c087787df93278

commit bd521f2a832ef1b4ea1a7680c0c087787df93278
Author: David Bauer <mail at david-bauer.net>
AuthorDate: Wed Jul 28 13:38:07 2021 +0200

    Revert "generic: add mac-address property for NVMEM mac addresses"
    
    This reverts commit b30924873062be47250e6b872347461c8221688d.
    
    This commit could create a property without allocated memory, breaking
    subsequent reads over a nodes property. Also, the mac-address-increment
    was not applied when reading from nvmem.
    
    Revert this commit for now, which breaks the label-mac-address logic.
    Possibly, traversing the device-tree from the netdev side is easier
    anyways.
    
    Signed-off-by: David Bauer <mail at david-bauer.net>
---
 .../683-NET-add-mac-address-property.patch         | 59 ----------------------
 .../683-NET-add-mac-address-property.patch         | 59 ----------------------
 2 files changed, 118 deletions(-)

diff --git a/target/linux/generic/hack-5.10/683-NET-add-mac-address-property.patch b/target/linux/generic/hack-5.10/683-NET-add-mac-address-property.patch
deleted file mode 100644
index de561c5336..0000000000
--- a/target/linux/generic/hack-5.10/683-NET-add-mac-address-property.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From: David Bauer <mail at david-bauer.net>
-Date: Tue, 20 Jul 2021 22:00:10 +0200
-Subject: [PATCH] generic: add mac-address property for NVMEM mac addresses
-
-Traversing the device-tree by referencing a network device to determine
-a devices labe-mac does not work with the generic nvmem implementation,
-as the userspace expects the MAC-address to be available as a
-device-tree property.
-
-The legacy mtd-mac-address implementation did create such a node. Do the
-same when using the nvmem implementation to allow reading the MAC
-address.
-
-Fixes commit d284e6ef0f06 ("treewide: convert mtd-mac-address-increment*
-to generic implementation")
-
-Signed-off-by: David Bauer <mail at david-bauer.net>
-
---- a/drivers/of/of_net.c
-+++ b/drivers/of/of_net.c
-@@ -61,6 +61,7 @@ static void *of_get_mac_addr_nvmem(struc
- 	void *mac;
- 	u8 nvmem_mac[ETH_ALEN];
- 	struct platform_device *pdev = of_find_device_by_node(np);
-+	struct property *prop;
- 
- 	if (!pdev) {
- 		*err = -ENODEV;
-@@ -78,10 +79,29 @@ static void *of_get_mac_addr_nvmem(struc
- 	put_device(&pdev->dev);
- 	if (!mac) {
- 		*err = -ENOMEM;
--		return NULL;
-+		goto out_err;
-+	}
-+
-+	prop = devm_kzalloc(&pdev->dev, sizeof(*prop), GFP_KERNEL);
-+	if (!prop) {
-+		*err = -ENOMEM;
-+		goto out_err;
-+	}
-+	prop->name = "mac-address";
-+	prop->length = ETH_ALEN;
-+	prop->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
-+	if (!prop->value || of_add_property(np, prop)) {
-+		*err = -ENOMEM;
-+		goto out_err;
- 	}
- 
- 	return mac;
-+
-+out_err:
-+	devm_kfree(&pdev->dev, prop->value);
-+	devm_kfree(&pdev->dev, prop);
-+	devm_kfree(&pdev->dev, mac);
-+	return NULL;
- }
- 
- static void *of_get_mac_address_mtd(struct device_node *np)
diff --git a/target/linux/generic/hack-5.4/683-NET-add-mac-address-property.patch b/target/linux/generic/hack-5.4/683-NET-add-mac-address-property.patch
deleted file mode 100644
index f0418dbb70..0000000000
--- a/target/linux/generic/hack-5.4/683-NET-add-mac-address-property.patch
+++ /dev/null
@@ -1,59 +0,0 @@
-From: David Bauer <mail at david-bauer.net>
-Date: Tue, 20 Jul 2021 22:00:10 +0200
-Subject: [PATCH] generic: add mac-address property for NVMEM mac addresses
-
-Traversing the device-tree by referencing a network device to determine
-a devices labe-mac does not work with the generic nvmem implementation,
-as the userspace expects the MAC-address to be available as a
-device-tree property.
-
-The legacy mtd-mac-address implementation did create such a node. Do the
-same when using the nvmem implementation to allow reading the MAC
-address.
-
-Fixes commit d284e6ef0f06 ("treewide: convert mtd-mac-address-increment*
-to generic implementation")
-
-Signed-off-by: David Bauer <mail at david-bauer.net>
-
---- a/drivers/of/of_net.c
-+++ b/drivers/of/of_net.c
-@@ -55,6 +55,7 @@ static void *of_get_mac_addr_nvmem(struc
- 	void *mac;
- 	u8 nvmem_mac[ETH_ALEN];
- 	struct platform_device *pdev = of_find_device_by_node(np);
-+	struct property *prop;
- 
- 	if (!pdev) {
- 		*err = -ENODEV;
-@@ -72,10 +73,29 @@ static void *of_get_mac_addr_nvmem(struc
- 	put_device(&pdev->dev);
- 	if (!mac) {
- 		*err = -ENOMEM;
--		return NULL;
-+		goto out_err;
-+	}
-+
-+	prop = devm_kzalloc(&pdev->dev, sizeof(*prop), GFP_KERNEL);
-+	if (!prop) {
-+		*err = -ENOMEM;
-+		goto out_err;
-+	}
-+	prop->name = "mac-address";
-+	prop->length = ETH_ALEN;
-+	prop->value = devm_kmemdup(&pdev->dev, mac, ETH_ALEN, GFP_KERNEL);
-+	if (!prop->value || of_add_property(np, prop)) {
-+		*err = -ENOMEM;
-+		goto out_err;
- 	}
- 
- 	return mac;
-+
-+out_err:
-+	devm_kfree(&pdev->dev, prop->value);
-+	devm_kfree(&pdev->dev, prop);
-+	devm_kfree(&pdev->dev, mac);
-+	return NULL;
- }
- 
- static void *of_get_mac_address_mtd(struct device_node *np)



More information about the lede-commits mailing list