[PATCH] nvmem: avoid false positive in of_nvmem_find() and simplify it

Enrico Scholz enrico.scholz at sigma-chemnitz.de
Wed Feb 10 09:27:04 EST 2021


of_nvmem_find() compared only the node names which can return the
wrong device in setups like

|  &i2c1 {
|      eeprom at 50 {
|      };
|  };
|  &i2c2 {
|      eeprom at 50 {
|      };
|  };

Instead of checking the complete path ('full_name' attribute), the
patch compares the device_node pointers directly.

This is done in other places (e.g. of_find_i2c_adapter_by_node()) and
in the linux kernel too.

Signed-off-by: Enrico Scholz <enrico.scholz at sigma-chemnitz.de>
---
 drivers/nvmem/core.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 06e1414769aa..02d0af6e1de0 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -129,7 +129,7 @@ static struct nvmem_device *of_nvmem_find(struct device_node *nvmem_np)
 		return NULL;
 
 	list_for_each_entry(dev, &nvmem_devs, node)
-		if (dev->dev.device_node->name && !strcmp(dev->dev.device_node->name, nvmem_np->name))
+		if (dev->dev.device_node == nvmem_np)
 			return dev;
 
 	return NULL;
-- 
2.29.2




More information about the barebox mailing list