Re: [PATCH v3 2/2] nvmem: core: skip nodes with compatibles other than "nvmem-cell"

From: Srinivas Kandagatla
Date: Mon May 11 2020 - 07:33:52 EST




On 28/04/2020 12:18, Ahmad Fatoum wrote:
The nvmem cell binding used to apply to all objects which match
"^.*@[0-9a-f]+$", without taking a compatible into account, which
precluded extension of EEPROMs by child nodes other than nvmem.

A previous commit changed the binding, so that nvmem cells that
feature a compatible property must have "nvmem-cell" as the value,
otherwise they are skipped.

Adjust the driver to observe the new binding change. This change
does not change behavior for any device tree that was already
compliant with the nvmem binding.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>

Thanks for the patch, this looks good to me, lets wait for Rob to ack the bindings!

--srini
---
drivers/nvmem/core.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 05c6ae4b0b97..eb697f5ad07d 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -547,6 +547,10 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
parent = dev->of_node;
for_each_child_of_node(parent, child) {
+ if (of_find_property(child, "compatible", NULL) &&
+ !of_device_is_compatible(child, "nvmem-cell"))
+ continue;
+
addr = of_get_property(child, "reg", &len);
if (!addr || (len < 2 * sizeof(u32))) {
dev_err(dev, "nvmem: invalid reg on %pOF\n", child);