[PATCH] Refer FDT tokens with symbolic names

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Replace hardcoded FDT structure block tokens with proper names to
improve code readability.

Signed-off-by: Sourabh Jain <sourabhjain@xxxxxxxxxxxxx>
---
 kexec/fs2dt.c | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/kexec/fs2dt.c b/kexec/fs2dt.c
index 1a43058..993b73b 100644
--- a/kexec/fs2dt.c
+++ b/kexec/fs2dt.c
@@ -32,6 +32,7 @@
 #include <stdio.h>
 #include "kexec.h"
 #include "fs2dt.h"
+#include "libfdt/fdt.h"
 
 #define MAXPATH 1024		/* max path name length */
 #define NAMESPACE 16384		/* max bytes for property names */
@@ -306,7 +307,7 @@ static void add_dyn_reconf_usable_mem_property__(int fd)
 	 * Add linux,drconf-usable-memory property.
 	 */
 	dt_reserve(&dt, 4+((rlen + 3)/4));
-	*dt++ = cpu_to_be32(3);
+	*dt++ = cpu_to_be32(FDT_PROP);
 	*dt++ = cpu_to_be32(rlen);
 	*dt++ = cpu_to_be32(propnum("linux,drconf-usable-memory"));
 	pad_structure_block(rlen);
@@ -380,7 +381,7 @@ static void add_usable_mem_property(int fd, size_t len)
 	 * No add linux,usable-memory property.
 	 */
 	dt_reserve(&dt, 4+((rlen + 3)/4));
-	*dt++ = cpu_to_be32(3);
+	*dt++ = cpu_to_be32(FDT_PROP);
 	*dt++ = cpu_to_be32(rlen);
 	*dt++ = cpu_to_be32(propnum("linux,usable-memory"));
 	pad_structure_block(rlen);
@@ -451,7 +452,7 @@ static void putprops(char *fn, struct dirent **nlist, int numlist)
 		len = statbuf.st_size;
 
 		dt_reserve(&dt, 4+((len + 3)/4));
-		*dt++ = cpu_to_be32(3);
+		*dt++ = cpu_to_be32(FDT_PROP);
 		*dt++ = cpu_to_be32(len);
 		*dt++ = cpu_to_be32(propnum(fn));
 		pad_structure_block(len);
@@ -586,7 +587,7 @@ static void putnode(void)
 	 * So round up & include the \0:
 	 */
 	dt_reserve(&dt, 1+((plen + 4)/4));
-	*dt++ = cpu_to_be32(1);
+	*dt++ = cpu_to_be32(FDT_BEGIN_NODE);
 	strcpy((void *)dt, *basename ? basename : "");
 	dt += ((plen + 4)/4);
 
@@ -602,7 +603,7 @@ static void putnode(void)
 		uint64_t bevalue;
 
 		dt_reserve(&dt, 12); /* both props, of 6 words ea. */
-		*dt++ = cpu_to_be32(3);
+		*dt++ = cpu_to_be32(FDT_PROP);
 		*dt++ = cpu_to_be32(len);
 		*dt++ = cpu_to_be32(propnum("linux,initrd-start"));
 		pad_structure_block(len);
@@ -612,7 +613,7 @@ static void putnode(void)
 		dt += (len + 3)/4;
 
 		len = 8;
-		*dt++ = cpu_to_be32(3);
+		*dt++ = cpu_to_be32(FDT_PROP);
 		*dt++ = cpu_to_be32(len);
 		*dt++ = cpu_to_be32(propnum("linux,initrd-end"));
 
@@ -656,7 +657,7 @@ static void putnode(void)
 
 		/* add new bootargs */
 		dt_reserve(&dt, 4+((cmd_len+3)/4));
-		*dt++ = cpu_to_be32(3);
+		*dt++ = cpu_to_be32(FDT_PROP);
 		*dt++ = cpu_to_be32(cmd_len);
 		*dt++ = cpu_to_be32(propnum("bootargs"));
 		pad_structure_block(cmd_len);
@@ -757,7 +758,7 @@ no_debug:
 	}
 
 	dt_reserve(&dt, 1);
-	*dt++ = cpu_to_be32(2);
+	*dt++ = cpu_to_be32(FDT_END_NODE);
 	dn[-1] = '\0';
 	free(namelist);
 }
@@ -796,7 +797,7 @@ static void add_boot_block(char **bufp, off_t *sizep)
 	len = _ALIGN(len, 4);
 	bb->totalsize = cpu_to_be32(be32_to_cpu(bb->off_dt_strings) + len);
 
-	bb->magic = cpu_to_be32(0xd00dfeed);
+	bb->magic = cpu_to_be32(FDT_MAGIC);
 	bb->version = cpu_to_be32(BOOT_BLOCK_VERSION);
 	bb->last_comp_version = cpu_to_be32(BOOT_BLOCK_LAST_COMP_VERSION);
 
@@ -844,7 +845,7 @@ void create_flatten_tree(char **bufp, off_t *sizep, const char *cmdline)
 
 	putnode();
 	dt_reserve(&dt, 1);
-	*dt++ = cpu_to_be32(9);
+	*dt++ = cpu_to_be32(FDT_END);
 
 	add_boot_block(bufp, sizep);
 	free(dt_base);
-- 
2.31.1


_______________________________________________
kexec mailing list
kexec@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/kexec



[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux