[PATCH 2/5] nvmem: core: read OF defined NVMEM cell name from "label" property

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Rafał Miłecki <rafal@xxxxxxxxxx>

Prefer it over $nodename. Property "label" allows more fancy /
customized names with special characters.

Signed-off-by: Rafał Miłecki <rafal@xxxxxxxxxx>
---
 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




[Index of Archives]     [Device Tree Compilter]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux PCI Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Yosemite Backpacking]


  Powered by Linux