dm: core: Correct low cell in ofnode_read_pci_addr()
authorSimon Glass <sjg@chromium.org>
Wed, 25 Sep 2019 14:55:46 +0000 (08:55 -0600)
committerBin Meng <bmeng.cn@gmail.com>
Thu, 3 Oct 2019 13:10:11 +0000 (21:10 +0800)
This reads the low cell of the PCI address from the wrong cell. Fix it.
Also fix the function that this code came from.

Fixes: 9e51204527 (dm: core: Add operations on device tree references)
Fixes: 4ea5243a3a (fdt: fix fdtdec_get_pci_addr() for CONFIG_PHYS_64BIT)
Signed-off-by: Simon Glass <sjg@chromium.org>
Tested-by: Stephen Warren <swarren@nvidia.com>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
drivers/core/ofnode.c
lib/fdtdec.c

index 7eca00cd6613622b5adbd9b9bebde1a0f1575995..5d47eccf1d1f6f29464f203203fa067d7fda2e72 100644 (file)
@@ -617,7 +617,7 @@ int ofnode_read_pci_addr(ofnode node, enum fdt_pci_space type,
                        if ((fdt32_to_cpu(*cell) & type) == type) {
                                addr->phys_hi = fdt32_to_cpu(cell[0]);
                                addr->phys_mid = fdt32_to_cpu(cell[1]);
-                               addr->phys_lo = fdt32_to_cpu(cell[1]);
+                               addr->phys_lo = fdt32_to_cpu(cell[2]);
                                break;
                        }
 
index 74525c84e7bd946920ddcef7efc27ddd32912266..74430c8b2ffd219fd0b1099177f4ca4503eecaac 100644 (file)
@@ -217,7 +217,7 @@ int fdtdec_get_pci_addr(const void *blob, int node, enum fdt_pci_space type,
                        if ((fdt32_to_cpu(*cell) & type) == type) {
                                addr->phys_hi = fdt32_to_cpu(cell[0]);
                                addr->phys_mid = fdt32_to_cpu(cell[1]);
-                               addr->phys_lo = fdt32_to_cpu(cell[1]);
+                               addr->phys_lo = fdt32_to_cpu(cell[2]);
                                break;
                        }