
At present fdt_read_prop() can only handle 1 or 2 cells. It is called by fdt_read_range() which may be used to read PCI address from <ranges> for a PCI bus node where the number of PCI address cell is 3.
This adds the special handling of such case.
Signed-off-by: Bin Meng bmeng.cn@gmail.com ---
common/fdt_support.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/common/fdt_support.c b/common/fdt_support.c index 638eca9..b3aa865 100644 --- a/common/fdt_support.c +++ b/common/fdt_support.c @@ -1602,22 +1602,31 @@ u64 fdt_get_base_address(const void *fdt, int node) }
/* - * Read a property of size <prop_len>. Currently only supports 1 or 2 cells. + * Read a property of size <prop_len>. Currently only supports 1 or 2 cells, + * or 3 cells specially for a PCI address. */ static int fdt_read_prop(const fdt32_t *prop, int prop_len, int cell_off, uint64_t *val, int cells) { - const fdt32_t *prop32 = &prop[cell_off]; - const unaligned_fdt64_t *prop64 = (const fdt64_t *)&prop[cell_off]; + const fdt32_t *prop32; + const unaligned_fdt64_t *prop64;
if ((cell_off + cells) > prop_len) return -FDT_ERR_NOSPACE;
+ prop32 = &prop[cell_off]; + + /* Special handling for PCI address in PCI bus <ranges> */ + if (cells == 3) + cell_off += 1; + prop64 = (const fdt64_t *)&prop[cell_off]; + switch (cells) { case 1: *val = fdt32_to_cpu(*prop32); break; case 2: + case 3: *val = fdt64_to_cpu(*prop64); break; default: