Skip to contentSkip to conversation

core: ofnode: Fix ofnode_get_addr_index function

PATCH New Keerthy 4 participants 8 messages Nov 19, 2018 – Feb 21, 2019

lore
Share & tools
lore

Keerthy

author
#0 lore raw

v3 cover 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(-)
Signature · 1 line
1.9.1
author
#1 lore raw

PATCH v3 1/2 core: ofnode: Fix ofnode_get_addr_index function

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.

---
 drivers/core/ofnode.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)
drivers/core/ofnode.c +10 -7
index d9b5280..0e584c1 100644
@@ -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;
Signature · 1 line
1.9.1
#2 lore raw

PATCH v3 1/2 core: ofnode: Fix ofnode_get_addr_index function

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.

---
 drivers/core/ofnode.c | 17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

Applied to u-boot-dm/master, thanks!

author
#3 lore raw

PATCH v3 2/2 core: ofnode: Add ofnode_get_addr_size_index

In reply to Keerthy

Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.

---
 drivers/core/ofnode.c | 14 ++++++++++----
 include/dm/ofnode.h   | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)
drivers/core/ofnode.c +10 -4
index 0e584c1..db29a33 100644
@@ -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);
include/dm/ofnode.h +14 -0
index 2fc9fa3..8bfe062 100644
@@ -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
Signature · 1 line
1.9.1
#4 lore raw

PATCH v3 2/2 core: ofnode: Add ofnode_get_addr_size_index

Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.

---
 drivers/core/ofnode.c | 14 ++++++++++----
 include/dm/ofnode.h   | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)

Applied to u-boot-dm/master, thanks!

#5 lore raw

PATCH v3 2/2 core: ofnode: Add ofnode_get_addr_size_index

Hi Simon,

Quoted 11 lines · sjg at google.com

Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.

---
  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

#6 lore raw

PATCH v3 2/2 core: ofnode: Add ofnode_get_addr_size_index

Quoted 12 lines · Lokesh Vutla

Hi Simon,

Quoted 9 lines · sjg at google.com

Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.

---
 drivers/core/ofnode.c | 14 ++++++++++----
 include/dm/ofnode.h   | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)
Quoted 4 lines
Quoted 2 lines

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.

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20181210/60be4111/attachment.sig>
author
#7 lore raw

PATCH v3 2/2 core: ofnode: Add ofnode_get_addr_size_index

Quoted 13 lines · Tom Rini
Quoted 12 lines · Lokesh Vutla

Hi Simon,

Quoted 9 lines · sjg at google.com

Add ofnode_get_addr_size_index function to fetch the address and size of the reg space based on index.

---
 drivers/core/ofnode.c | 14 ++++++++++----
 include/dm/ofnode.h   | 14 ++++++++++++++
 2 files changed, 24 insertions(+), 4 deletions(-)
Quoted 8 lines
Quoted 4 lines
Quoted 2 lines

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

Quoted 1 line