[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211223110755.22722-3-zajec5@gmail.com>
Date: Thu, 23 Dec 2021 12:07:52 +0100
From: Rafał Miłecki <zajec5@...il.com>
To: Srinivas Kandagatla <srinivas.kandagatla@...aro.org>,
Rob Herring <robh+dt@...nel.org>
Cc: devicetree@...r.kernel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org,
Rafał Miłecki <rafal@...ecki.pl>
Subject: [PATCH 2/5] nvmem: core: read OF defined NVMEM cell name from "label" property
From: Rafał Miłecki <rafal@...ecki.pl>
Prefer it over $nodename. Property "label" allows more fancy /
customized names with special characters.
Signed-off-by: Rafał Miłecki <rafal@...ecki.pl>
---
drivers/nvmem/core.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 23a38dcf0fc4..45c39ac401bd 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -685,6 +685,7 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
struct device *dev = &nvmem->dev;
struct nvmem_cell_entry *cell;
const __be32 *addr;
+ const char *label;
int len;
parent = dev->of_node;
@@ -708,7 +709,11 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
cell->nvmem = nvmem;
cell->offset = be32_to_cpup(addr++);
cell->bytes = be32_to_cpup(addr);
- cell->name = kasprintf(GFP_KERNEL, "%pOFn", child);
+
+ if (!of_property_read_string(child, "label", &label))
+ cell->name = kasprintf(GFP_KERNEL, "%s", label);
+ else
+ cell->name = kasprintf(GFP_KERNEL, "%pOFn", child);
addr = of_get_property(child, "bits", &len);
if (addr && len == (2 * sizeof(u32))) {
--
2.31.1
Powered by blists - more mailing lists