[U-Boot] [PATCH v3 0/2] core: ofnode: Fix ofnode_get_addr_index function

The series adds a fix to ofnode_get_addr_index function and also adds a new ofnode_get_addr_size_index function.
Changes in v3:
Fixed compilation issues with sandbox_defconfig
Keerthy (2): core: ofnode: Fix ofnode_get_addr_index function core: ofnode: Add ofnode_get_addr_size_index
drivers/core/ofnode.c | 25 +++++++++++++++++-------- include/dm/ofnode.h | 14 ++++++++++++++ 2 files changed, 31 insertions(+), 8 deletions(-)

Currently the else part of ofnode_get_addr_index function does not fetch addresses based on the index but rather just returns the base address. Fix that.
Signed-off-by: Keerthy j-keerthy@ti.com --- drivers/core/ofnode.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index d9b5280..0e584c1 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -253,15 +253,15 @@ int ofnode_read_size(ofnode node, const char *propname)
fdt_addr_t ofnode_get_addr_index(ofnode node, int index) { + int na, ns; + fdt_size_t size; + if (ofnode_is_np(node)) { const __be32 *prop_val; uint flags; - u64 size; - int na; - int ns;
- prop_val = of_get_address(ofnode_to_np(node), index, &size, - &flags); + prop_val = of_get_address(ofnode_to_np(node), index, + (u64 *)&size, &flags); if (!prop_val) return FDT_ADDR_T_NONE;
@@ -274,8 +274,11 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index) return of_read_number(prop_val, na); } } else { - return fdt_get_base_address(gd->fdt_blob, - ofnode_to_offset(node)); + na = ofnode_read_simple_addr_cells(ofnode_get_parent(node)); + ns = ofnode_read_simple_size_cells(ofnode_get_parent(node)); + return fdtdec_get_addr_size_fixed(gd->fdt_blob, + ofnode_to_offset(node), "reg", + index, na, ns, &size, true); }
return FDT_ADDR_T_NONE;

Currently the else part of ofnode_get_addr_index function does not fetch addresses based on the index but rather just returns the base address. Fix that.
Signed-off-by: Keerthy j-keerthy@ti.com --- drivers/core/ofnode.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-)
Applied to u-boot-dm/master, thanks!

Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.
Signed-off-by: Keerthy j-keerthy@ti.com --- drivers/core/ofnode.c | 14 ++++++++++---- include/dm/ofnode.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/drivers/core/ofnode.c b/drivers/core/ofnode.c index 0e584c1..db29a33 100644 --- a/drivers/core/ofnode.c +++ b/drivers/core/ofnode.c @@ -251,17 +251,16 @@ int ofnode_read_size(ofnode node, const char *propname) return -EINVAL; }
-fdt_addr_t ofnode_get_addr_index(ofnode node, int index) +fdt_addr_t ofnode_get_addr_size_index(ofnode node, int index, fdt_size_t *size) { int na, ns; - fdt_size_t size;
if (ofnode_is_np(node)) { const __be32 *prop_val; uint flags;
prop_val = of_get_address(ofnode_to_np(node), index, - (u64 *)&size, &flags); + (u64 *)size, &flags); if (!prop_val) return FDT_ADDR_T_NONE;
@@ -278,12 +277,19 @@ fdt_addr_t ofnode_get_addr_index(ofnode node, int index) ns = ofnode_read_simple_size_cells(ofnode_get_parent(node)); return fdtdec_get_addr_size_fixed(gd->fdt_blob, ofnode_to_offset(node), "reg", - index, na, ns, &size, true); + index, na, ns, size, true); }
return FDT_ADDR_T_NONE; }
+fdt_addr_t ofnode_get_addr_index(ofnode node, int index) +{ + fdt_size_t size; + + return ofnode_get_addr_size_index(node, index, &size); +} + fdt_addr_t ofnode_get_addr(ofnode node) { return ofnode_get_addr_index(node, 0); diff --git a/include/dm/ofnode.h b/include/dm/ofnode.h index 2fc9fa3..8bfe062 100644 --- a/include/dm/ofnode.h +++ b/include/dm/ofnode.h @@ -356,6 +356,20 @@ int ofnode_read_size(ofnode node, const char *propname); phys_addr_t ofnode_get_addr_index(ofnode node, int index);
/** + * ofnode_get_addr_size_index() - get an address/size from a node + * based on index + * + * This reads the register address from a node + * + * @node: node to read from + * @index: Index of address to read (0 for first) + * @size: Pointer to size of the address + * @return address, or FDT_ADDR_T_NONE if not present or invalid + */ +phys_addr_t ofnode_get_addr_size_index(ofnode node, int index, + fdt_size_t *size); + +/** * ofnode_get_addr() - get an address from a node * * This reads the register address from a node

Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.
Signed-off-by: Keerthy j-keerthy@ti.com --- drivers/core/ofnode.c | 14 ++++++++++---- include/dm/ofnode.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-)
Applied to u-boot-dm/master, thanks!

Hi Simon,
On 29/11/18 11:12 PM, sjg@google.com wrote:
Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.
Signed-off-by: Keerthy j-keerthy@ti.com
drivers/core/ofnode.c | 14 ++++++++++---- include/dm/ofnode.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-)
Applied to u-boot-dm/master, thanks!
I do not see this patch in master branch. Any reason why this is dropped?
Thanks and regards, Lokesh

On Mon, Dec 10, 2018 at 07:15:17PM +0530, Lokesh Vutla wrote:
Hi Simon,
On 29/11/18 11:12 PM, sjg@google.com wrote:
Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.
Signed-off-by: Keerthy j-keerthy@ti.com
drivers/core/ofnode.c | 14 ++++++++++---- include/dm/ofnode.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-)
Applied to u-boot-dm/master, thanks!
I do not see this patch in master branch. Any reason why this is dropped?
As I reported in https://patchwork.ozlabs.org/patch/1005644/ this breaks test.py on sandbox for non-obvious reasons and Keerthy said they'll look into it.

On 10/12/18 7:25 PM, Tom Rini wrote:
On Mon, Dec 10, 2018 at 07:15:17PM +0530, Lokesh Vutla wrote:
Hi Simon,
On 29/11/18 11:12 PM, sjg@google.com wrote:
Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.
Signed-off-by: Keerthy j-keerthy@ti.com
drivers/core/ofnode.c | 14 ++++++++++---- include/dm/ofnode.h | 14 ++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-)
Applied to u-boot-dm/master, thanks!
I do not see this patch in master branch. Any reason why this is dropped?
As I reported in https://patchwork.ozlabs.org/patch/1005644/ this breaks test.py on sandbox for non-obvious reasons and Keerthy said they'll look into it.
Tom,
Failing case as pointed previously:
https://travis-ci.org/trini/u-boot/jobs/461494951
I applied the same patch on latest master and here are the results:
https://travis-ci.org/lokeshvutla/u-boot/builds/496417722
the clang test.py test cases pass with this patch applied on latest master. Please let me know if this patch still causes issues if i need to trigger different tests.
I will resend this patch on top of master if your tests are okay.
Regards, Keerthy
participants (4)
-
Keerthy
-
Lokesh Vutla
-
sjg@google.com
-
Tom Rini