All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] nvmem: core: don't consider subnodes not matching binding
@ 2020-03-23 15:28 Ahmad Fatoum
  2020-04-06 11:29 ` Ahmad Fatoum
  2020-04-06 12:33 ` Srinivas Kandagatla
  0 siblings, 2 replies; 6+ messages in thread
From: Ahmad Fatoum @ 2020-03-23 15:28 UTC (permalink / raw)
  To: Srinivas Kandagatla; +Cc: kernel, Christian Eggers, Ahmad Fatoum, linux-kernel

The nvmem cell binding applies to objects which match "^.*@[0-9a-f]+$",
but so far the driver has matched all objects and failed if they didn't
have the expected properties.

The driver's behavior in this regard precludes future extension of
EEPROMs by child nodes other than nvmem and clashes with the barebox
bootloader binding that extends the fixed-partitions MTD binding to
EEPROMs as it tries to interpret the "fixed-partitions"-compatible
partitions node as a nvmem cell.

Solve this issue by skipping all subnodes that don't contain an @.

This still allows for cell names like `partitions@0,0', but this
is much less likely to cause future collisions.

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
  use ->full_name instead of ->name as to not break existing correct
  cells (Christian)
---
 drivers/nvmem/core.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index ef326f243f36..f051051fb1a8 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -278,6 +278,8 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
 	parent = dev->of_node;
 
 	for_each_child_of_node(parent, child) {
+		if (!strchr(kbasename(child->full_name), '@'))
+			continue;
 		addr = of_get_property(child, "reg", &len);
 		if (!addr || (len < 2 * sizeof(u32))) {
 			dev_err(dev, "nvmem: invalid reg on %pOF\n", child);
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-04-15  8:46 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-23 15:28 [PATCH v2] nvmem: core: don't consider subnodes not matching binding Ahmad Fatoum
2020-04-06 11:29 ` Ahmad Fatoum
2020-04-06 12:33 ` Srinivas Kandagatla
2020-04-06 14:20   ` Ahmad Fatoum
2020-04-15  8:05     ` Ahmad Fatoum
2020-04-15  8:46       ` Srinivas Kandagatla

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.