Patch "nvmem: core: skip child nodes not matching binding" has been added to the 5.10-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    nvmem: core: skip child nodes not matching binding

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     nvmem-core-skip-child-nodes-not-matching-binding.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 117fbc15bab38cdc70a8ba3f293c42f5844f2d89
Author: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
Date:   Fri Jan 29 17:14:30 2021 +0000

    nvmem: core: skip child nodes not matching binding
    
    [ Upstream commit 0445efacec75b85c2a3c176957ee050ba9be53f0 ]
    
    The nvmem cell binding applies to all eeprom child nodes matching
    "^.*@[0-9a-f]+$" without taking a compatible into account.
    
    Linux drivers, like at24, are even more extensive and assume
    _all_ at24 eeprom child nodes to be nvmem cells since e888d445ac33
    ("nvmem: resolve cells from DT at registration time").
    
    Since df5f3b6f5357 ("dt-bindings: nvmem: stm32: new property for
    data access"), the additionalProperties: True means it's Ok to have
    other properties as long as they don't match "^.*@[0-9a-f]+$".
    
    The barebox bootloader extends the MTD partitions binding to
    EEPROM and can fix up following device tree node:
    
      &eeprom {
        partitions {
          compatible = "fixed-partitions";
        };
      };
    
    This is allowed binding-wise, but drivers using nvmem_register()
    like at24 will fail to parse because the function expects all child
    nodes to have a reg property present. This results in the whole
    EEPROM driver probe failing despite the device tree being correct.
    
    Fix this by skipping nodes lacking a reg property instead of
    returning an error. This effectively makes the drivers adhere
    to the binding because all nodes with a unit address must have
    a reg property and vice versa.
    
    Fixes: e888d445ac33 ("nvmem: resolve cells from DT at registration time").
    Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
    Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20210129171430.11328-6-srinivas.kandagatla@xxxxxxxxxx
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/nvmem/core.c b/drivers/nvmem/core.c
index 1a3460a8e73ab..9b6ab83956c3b 100644
--- a/drivers/nvmem/core.c
+++ b/drivers/nvmem/core.c
@@ -545,7 +545,9 @@ static int nvmem_add_cells_from_of(struct nvmem_device *nvmem)
 
 	for_each_child_of_node(parent, child) {
 		addr = of_get_property(child, "reg", &len);
-		if (!addr || (len < 2 * sizeof(u32))) {
+		if (!addr)
+			continue;
+		if (len < 2 * sizeof(u32)) {
 			dev_err(dev, "nvmem: invalid reg on %pOF\n", child);
 			return -EINVAL;
 		}



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux