lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220825214423.903672-14-michael@walle.cc>
Date:   Thu, 25 Aug 2022 23:44:22 +0200
From:   Michael Walle <michael@...le.cc>
To:     Miquel Raynal <miquel.raynal@...tlin.com>,
        Richard Weinberger <richard@....at>,
        Vignesh Raghavendra <vigneshr@...com>,
        Rob Herring <robh+dt@...nel.org>,
        Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
        Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
        Shawn Guo <shawnguo@...nel.org>, Li Yang <leoyang.li@....com>,
        Rafał Miłecki <rafal@...ecki.pl>,
        "David S . Miller" <davem@...emloft.net>,
        Eric Dumazet <edumazet@...gle.com>,
        Jakub Kicinski <kuba@...nel.org>,
        Paolo Abeni <pabeni@...hat.com>,
        Frank Rowand <frowand.list@...il.com>
Cc:     linux-mtd@...ts.infradead.org, devicetree@...r.kernel.org,
        linux-kernel@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        netdev@...r.kernel.org, Ahmad Fatoum <a.fatoum@...gutronix.de>,
        Michael Walle <michael@...le.cc>
Subject: [RFC PATCH v1 13/14] nvmem: layouts: u-boot-env: add device node

Register the device node so we can actually make use of the cells from
within the device tree.

This obviously only works if the environment variable name can be mapped
to the device node, which isn't always the case. Think of "_" vs "-".
But for simple things like ethaddr, this will work.

Signed-off-by: Michael Walle <michael@...le.cc>
---
 drivers/nvmem/layouts/u-boot-env.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/nvmem/layouts/u-boot-env.c b/drivers/nvmem/layouts/u-boot-env.c
index 40b7e9a778c4..0901cc1f5acd 100644
--- a/drivers/nvmem/layouts/u-boot-env.c
+++ b/drivers/nvmem/layouts/u-boot-env.c
@@ -5,9 +5,11 @@
 
 #include <linux/crc32.h>
 #include <linux/dev_printk.h>
+#include <linux/device.h>
 #include <linux/mod_devicetable.h>
 #include <linux/nvmem-consumer.h>
 #include <linux/nvmem-provider.h>
+#include <linux/of.h>
 #include <linux/slab.h>
 
 enum u_boot_env_format {
@@ -26,7 +28,8 @@ struct u_boot_env_image_redundant {
 	u8 data[];
 } __packed;
 
-static int u_boot_env_add_cells(struct nvmem_device *nvmem, uint8_t *buf,
+static int u_boot_env_add_cells(struct device *dev,
+				struct nvmem_device *nvmem, uint8_t *buf,
 				size_t data_offset, size_t data_len)
 {
 	struct nvmem_cell_info info = {0};
@@ -46,6 +49,7 @@ static int u_boot_env_add_cells(struct nvmem_device *nvmem, uint8_t *buf,
 		info.name = var;
 		info.offset = data_offset + value - data;
 		info.bytes = strlen(value);
+		info.np = of_get_child_by_name(dev->of_node, var);
 
 		err = nvmem_add_one_cell(nvmem, &info);
 		if (err)
@@ -113,7 +117,7 @@ static int u_boot_add_cells(struct device *dev, struct nvmem_device *nvmem,
 	}
 
 	buf[size - 1] = '\0';
-	err = u_boot_env_add_cells(nvmem, buf, data_offset, data_len);
+	err = u_boot_env_add_cells(dev, nvmem, buf, data_offset, data_len);
 	if (err)
 		dev_err(dev, "Failed to add cells: %d\n", err);
 
-- 
2.30.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ