Skip to contentSkip to conversation

fdt helper cleanup related to phandle support.

PATCH New Kumar Gala 2 participants 6 messages Aug 1, 2011 – Aug 26, 2011 PowerPC

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

cover fdt helper cleanup related to phandle support.

Jerry,

Please review and Ack. I would like this to go via 85xx tree as the fman ethernet driver code depends on these changes.

thanks

- k

author
#1 lore raw

PATCH 1/2 fdt: Rename fdt_create_phandle to fdt_set_phandle

The old fdt_create_phandle didn't actually create a phandle it just set one. We'll introduce a new helper that actually does creation.

---
 arch/powerpc/cpu/mpc85xx/portals.c |    2 +-
 common/fdt_support.c               |    6 +++---
 include/fdt_support.h              |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
arch/powerpc/cpu/mpc85xx/portals.c +1 -1
index 65635e7..418dd9d 100644
@@ -151,7 +151,7 @@ static int fdt_qportal(void *blob, int off, int id, char *name,
 			dev_handle = fdt_get_phandle(blob, dev_off);
 			if (dev_handle <= 0) {
 				dev_handle = fdt_alloc_phandle(blob);
-				ret = fdt_create_phandle(blob, dev_off,
+				ret = fdt_set_phandle(blob, dev_off,
 							 dev_handle);
 				if (ret < 0)
 					return ret;
common/fdt_support.c +3 -3
index 19b2ef6..8f7323d 100644
@@ -1196,13 +1196,13 @@ int fdt_alloc_phandle(void *blob)
 }
 
 /*
- * fdt_create_phandle: Create a phandle property for the given node
+ * fdt_set_phandle: Create a phandle property for the given node
  *
  * @fdt: ptr to device tree
  * @nodeoffset: node to update
  * @phandle: phandle value to set (must be unique)
-*/
-int fdt_create_phandle(void *fdt, int nodeoffset, uint32_t phandle)
+ */
+int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle)
 {
 	int ret;
 
include/fdt_support.h +1 -1
index 863024f..fdb9307 100644
@@ -89,7 +89,7 @@ u64 fdt_translate_address(void *blob, int node_offset, const u32 *in_addr);
 int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
 					phys_addr_t compat_off);
 int fdt_alloc_phandle(void *blob);
-int fdt_create_phandle(void *fdt, int nodeoffset, uint32_t phandle);
+int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle);
 int fdt_add_edid(void *blob, const char *compat, unsigned char *buf);
 
 int fdt_verify_alias_address(void *fdt, int anode, const char *alias,
Signature · 1 line
1.7.3.4
author
#2 lore raw

PATCH 2/2 fdt: Add new fdt_create_phandle helper

Add a helper function that will return a phandle value for the given node. If the node doesn't have a phandle already one will be created.

---
 common/fdt_support.c  |   20 ++++++++++++++++++++
 include/fdt_support.h |    1 +
 2 files changed, 21 insertions(+), 0 deletions(-)
common/fdt_support.c +20 -0
index 8f7323d..46aa842 100644
@@ -1235,6 +1235,26 @@ int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle)
 	return ret;
 }
 
+/*
+ * fdt_create_phandle: Create a phandle property for the given node
+ *
+ * @fdt: ptr to device tree
+ * @nodeoffset: node to update
+ */
+int fdt_create_phandle(void *fdt, int nodeoffset)
+{
+	/* see if there is a phandle already */
+	int phandle = fdt_get_phandle(fdt, nodeoffset);
+
+	/* if we got 0, means no phandle so create one */
+	if (phandle == 0) {
+		phandle = fdt_alloc_phandle(fdt);
+		fdt_set_phandle(fdt, nodeoffset, phandle);
+	}
+
+	return phandle;
+}
+
 #if defined(CONFIG_VIDEO)
 int fdt_add_edid(void *blob, const char *compat, unsigned char *edid_buf)
 {
include/fdt_support.h +1 -0
index fdb9307..8f06aac 100644
@@ -90,6 +90,7 @@ int fdt_node_offset_by_compat_reg(void *blob, const char *compat,
 					phys_addr_t compat_off);
 int fdt_alloc_phandle(void *blob);
 int fdt_set_phandle(void *fdt, int nodeoffset, uint32_t phandle);
+int fdt_create_phandle(void *fdt, int nodeoffset);
 int fdt_add_edid(void *blob, const char *compat, unsigned char *buf);
 
 int fdt_verify_alias_address(void *fdt, int anode, const char *alias,
Signature · 1 line
1.7.3.4
#3 lore raw

PATCH 2/2 fdt: Add new fdt_create_phandle helper

Quoted 4 lines · Kumar Gala

Add a helper function that will return a phandle value for the given node. If the node doesn't have a phandle already one will be created.

Quoted 4 lines
---
  common/fdt_support.c  |   20 ++++++++++++++++++++
  include/fdt_support.h |    1 +
  2 files changed, 21 insertions(+), 0 deletions(-)

[snip]

Thanks,
gvb

#4 lore raw

PATCH 1/2 fdt: Rename fdt_create_phandle to fdt_set_phandle

In reply to Kumar Gala
Quoted 4 lines · Kumar Gala

The old fdt_create_phandle didn't actually create a phandle it just set one. We'll introduce a new helper that actually does creation.

Quoted 5 lines
---
  arch/powerpc/cpu/mpc85xx/portals.c |    2 +-
  common/fdt_support.c               |    6 +++---
  include/fdt_support.h              |    2 +-
  3 files changed, 5 insertions(+), 5 deletions(-)

[snip]

author Applied
#5 lore raw

cover fdt helper cleanup related to phandle support.

In reply to Kumar Gala
Quoted 6 lines · Kumar Gala

Jerry,

Please review and Ack. I would like this to go via 85xx tree as the fman ethernet driver code depends on these changes.

thanks

applied to 85xx next

- k