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

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

 



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

|  &i2c1 {
|      eeprom@50 {
|      };
|  };
|  &i2c2 {
|      eeprom@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@xxxxxxxxxxxxxxxxx>
---
 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


_______________________________________________
barebox mailing list
barebox@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux