[U-Boot] [PATCH v2 04/11] fdtdec: Implement fdtdec_set_phandle()

Thierry Reding thierry.reding at gmail.com
Tue Mar 12 13:00:57 UTC 2019


From: Thierry Reding <treding at nvidia.com>

This function can be used to set a phandle for a given node.

Signed-off-by: Thierry Reding <treding at nvidia.com>
---
Changes in v2:
- don't emit deprecated linux,phandle property

 include/fdtdec.h | 11 +++++++++++
 lib/fdtdec.c     |  7 +++++++
 2 files changed, 18 insertions(+)

diff --git a/include/fdtdec.h b/include/fdtdec.h
index b593c562584d..eb076fc24bc9 100644
--- a/include/fdtdec.h
+++ b/include/fdtdec.h
@@ -993,6 +993,17 @@ int fdtdec_setup_memory_banksize(void);
  */
 int fdtdec_generate_phandle(const void *blob, uint32_t *phandle);
 
+/**
+ * fdtdec_set_phandle() - sets the phandle of a given node
+ *
+ * @param blob		FDT blob
+ * @param node		offset in the FDT blob of the node whose phandle is to
+ *			be set
+ * @param phandle	phandle to set for the given node
+ * @return 0 on success or a negative error code on failure
+ */
+int fdtdec_set_phandle(void *blob, int node, uint32_t phandle);
+
 /**
  * Set up the device tree ready for use
  */
diff --git a/lib/fdtdec.c b/lib/fdtdec.c
index d384c84feb33..04d242cdf38e 100644
--- a/lib/fdtdec.c
+++ b/lib/fdtdec.c
@@ -1271,6 +1271,13 @@ int fdtdec_generate_phandle(const void *blob, uint32_t *phandle)
 	return 0;
 }
 
+int fdtdec_set_phandle(void *blob, int node, uint32_t phandle)
+{
+	fdt32_t value = cpu_to_fdt32(phandle);
+
+	return fdt_setprop(blob, node, "phandle", &value, sizeof(value));
+}
+
 int fdtdec_setup(void)
 {
 #if CONFIG_IS_ENABLED(OF_CONTROL)
-- 
2.20.1



More information about the U-Boot mailing list