Skip to contentSkip to conversation

mach-k3: common_fdt: Move carveout struct

PATCH Superseded Daniel Schultz 2 participants 2 messages Apr 10, 2025 – Apr 11, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 mach-k3: common_fdt: Move carveout struct

Labels are not allowed before declarations. Move the carveout struct at the beginning and only update 'end' at this point.

This will fix following error:

arch/arm/mach-k3/common_fdt.c: In function 'fdt_fixup_reserved':
arch/arm/mach-k3/common_fdt.c:156:2: error: a label can only be part of a statement and a declaration is not a statement

  156 |  struct fdt_memory carveout = {
      |  ^~~~~~

make[1]: *** [scripts/Makefile.build:256: arch/arm/mach-k3/common_fdt.o] Error 1
make: *** [Makefile:1919: arch/arm/mach-k3] Error 2

Fixes 096aa229a9e ("mach-k3: common_fdt: create a reserved memory node")

---
Changes in v2:
* Moved carveout struct at the beginning instead of adding an dummy statement.

 arch/arm/mach-k3/common_fdt.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
arch/arm/mach-k3/common_fdt.c +5 -4
index 361b0c0b31b..9437b923d49 100644
@@ -119,6 +119,10 @@ int fdt_fixup_reserved(void *blob, const char *name,
 {
 	int nodeoffset, subnode;
 	int ret;
+	struct fdt_memory carveout = {
+		.start = new_address,
+		.end = new_address + new_size - 1,
+	};
 
 	/* Find reserved-memory */
 	nodeoffset = fdt_subnode_offset(blob, 0, "reserved-memory");
@@ -153,10 +157,7 @@ int fdt_fixup_reserved(void *blob, const char *name,
 	}
 
 add_carveout:
-	struct fdt_memory carveout = {
-		.start = new_address,
-		.end = new_address + new_size - 1,
-	};
+	carveout.end = new_address + new_size - 1;
 	ret = fdtdec_add_reserved_memory(blob, name, &carveout, NULL, 0, NULL,
 					 FDTDEC_RESERVED_MEMORY_NO_MAP);
 	if (ret < 0)
Signature · 1 line
2.25.1
Reviewed-by on v2 1/1
#1 lore raw
Quoted 27 lines · Daniel Schultz

Labels are not allowed before declarations. Move the carveout struct at the beginning and only update 'end' at this point.

This will fix following error:

arch/arm/mach-k3/common_fdt.c: In function 'fdt_fixup_reserved':
arch/arm/mach-k3/common_fdt.c:156:2: error: a label can only be part of a statement and a declaration is not a statement

   156 |  struct fdt_memory carveout = {
       |  ^~~~~~

make[1]: *** [scripts/Makefile.build:256: arch/arm/mach-k3/common_fdt.o] Error 1
make: *** [Makefile:1919: arch/arm/mach-k3] Error 2

Fixes 096aa229a9e ("mach-k3: common_fdt: create a reserved memory node")

---
Changes in v2:
* Moved carveout struct at the beginning instead of adding an dummy statement.

  arch/arm/mach-k3/common_fdt.c | 9 +++++----
  1 file changed, 5 insertions(+), 4 deletions(-)
arch/arm/mach-k3/common_fdt.c +0 -0
index 361b0c0b31b..9437b923d49 100644

arch/arm/mach-k3/common_fdt.c int fdt_fixup_reserved(void *blob, const char *name, · line 124

Quoted 6 lines
arch/arm/mach-k3/common_fdt.c +3 -0
@@ -119,6 +119,10 @@ int fdt_fixup_reserved(void *blob, const char *name,
  {
  	int nodeoffset, subnode;
  	int ret;
+	struct fdt_memory carveout = {
+		.start = new_address,
+		.end = new_address + new_size - 1,

I think there is no need of assigning end here. As final value is updated at last.

With this change

Quoted 16 lines
arch/arm/mach-k3/common_fdt.c +2 -4
+	};
 
  	/* Find reserved-memory */
  	nodeoffset = fdt_subnode_offset(blob, 0, "reserved-memory");
@@ -153,10 +157,7 @@ int fdt_fixup_reserved(void *blob, const char *name,
  	}
 
  add_carveout:
-	struct fdt_memory carveout = {
-		.start = new_address,
-		.end = new_address + new_size - 1,
-	};
+	carveout.end = new_address + new_size - 1;
  	ret = fdtdec_add_reserved_memory(blob, name, &carveout, NULL, 0, NULL,
  					 FDTDEC_RESERVED_MEMORY_NO_MAP);
  	if (ret < 0)