lkml.org 
[lkml]   [2020]   [Feb]   [27]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[RFC PATCH] nvmem: core: don't consider subnodes not matching binding
Date
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>
---
Hello,

I am open to other suggestions on how to restrict nvmem from claiming
specific subnodes. I would have preferred a cells { } container, like the
partitons { } container used for MTD partitions, but as we have to stay
backward-compatible anyway, a solution is needed for the current binding
as well.

Cheers,
Ahmad
---
drivers/nvmem/core.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 1e4a798dce6e..1688287a765f 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -271,6 +271,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(child->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.0
\
 
 \ /
  Last update: 2020-02-27 10:51    [W:0.033 / U:1.244 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site