:: commit 288cb6e17e3a26f3b1d8269ebc2ca2c5af39bfc6

Kacper Słomiński <kacper.slominski72@gmail.com> — 2024-06-11 19:54

parents: 00b3025fd3

lib: Add helpers for adding 32-bit /chosen properties

diff --git a/common/lib/fdt.c b/common/lib/fdt.c
index c9ae0692..fb60cc0f 100644
--- a/common/lib/fdt.c
+++ b/common/lib/fdt.c
@@ -32,4 +32,13 @@ int fdt_set_chosen_uint64(void *fdt, const char *name, uint64_t value) {
     return fdt_setprop_u64(fdt, chosen_offset, name, value);
 }
 
+int fdt_set_chosen_uint32(void *fdt, const char *name, uint32_t value) {
+    int chosen_offset = fdt_get_or_add_chosen_node(fdt);
+    if (chosen_offset < 0) {
+        return chosen_offset;
+    }
+
+    return fdt_setprop_u32(fdt, chosen_offset, name, value);
+}
+
 #endif
diff --git a/common/lib/fdt.h b/common/lib/fdt.h
index 3edcc841..ba7a9a32 100644
--- a/common/lib/fdt.h
+++ b/common/lib/fdt.h
@@ -8,6 +8,7 @@
 
 int fdt_set_chosen_string(void *fdt, const char *name, const char *value);
 int fdt_set_chosen_uint64(void *fdt, const char *name, uint64_t value);
+int fdt_set_chosen_uint32(void *fdt, const char *name, uint32_t value);
 
 #endif
 
tab: 248 wrap: offon