Skip to contentSkip to conversation

fit: use constants for property names in mkimage, boot and SPL

PATCH Superseded Aristo Chen 4 participants 17 messages Sep 23 – Oct 7

lore
Share & tools
lore
#0 lore raw

cover fit: use constants for property names in mkimage, boot and SPL

include/image.h defines constants for the FIT property and node names, and most of the FIT code uses them, but mkimage, boot/ and the SPL FIT loader still spell a few of the names out as string literals. This series converts the remaining ones in those three areas, one patch each.

Most of the changes swap a literal for the matching constant. Two need a word of explanation. fdt_property_file() in mkimage already takes the property name as an argument but ignores it and hardcodes "data", so patch 1 uses the argument; every caller passes FIT_DATA_PROP. FIT_COMPAT_PROP was added for the compatible property of configuration nodes by commit 3059eb0c27dd ("boot/fit: declare (and use) new constant for conf's compatible prop"), which noted that the same property can appear in FPGA image nodes but did not convert those. Patches 2 and 3 use FIT_COMPAT_PROP for the FPGA image node as well, in U-Boot proper and in SPL.

No functional change is intended. Built for sandbox, sandbox_spl and dra7xx_evm (U-Boot proper, SPL and host tools), the objects of all touched files are identical before and after the series once debug info is stripped and the embedded version string is held fixed. The only exception is four __LINE__ values in boot/image-fit.c log calls, which move down by one where patch 2 wraps a line. Each patch builds for those three boards, and the sandbox FIT, vboot, mkimage and dm-verity pytests pass.

The series is based on next, where the dm-verity code touched by patch 2 lives.

Aristo Chen (3):
tools: mkimage: use constants for FIT property names
boot: fit: use constants for FIT property names
spl: fit: use constants for FIT property names

 boot/boot_fit.c      |  4 ++--
 boot/image-board.c   |  3 ++-
 boot/image-fit.c     |  3 ++-
 common/spl/spl_fit.c | 12 ++++++------
 tools/fit_image.c    |  2 +-
 tools/image-host.c   |  3 ++-
 6 files changed, 15 insertions(+), 12 deletions(-)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/3 tools: mkimage: use constants for FIT property names

include/image.h defines constants for the FIT property names, but mkimage still spells out two of them as string literals.

When the signing algorithm is given with -o, fit_image_write_sig() records it in the "algo" property of the signature node using a literal, while fit_image_hash_get_algo(), which mkimage and the verification code use to read that property, uses FIT_ALGO_PROP. Use the constant for the write as well.

fdt_property_file() takes the property name as an argument but ignores it and always writes "data". Every caller passes FIT_DATA_PROP, so use the argument.

No functional change.

---
 tools/fit_image.c  | 2 +-
 tools/image-host.c | 3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)
tools/fit_image.c +1 -1
index f7d11904472..077906889ca 100644
@@ -250,7 +250,7 @@ static int fdt_property_file(struct image_tool_params *params,
 		goto err;
 	}
 
-	ret = fdt_property_placeholder(fdt, "data", sbuf.st_size, &ptr);
+	ret = fdt_property_placeholder(fdt, name, sbuf.st_size, &ptr);
 	if (ret)
 		goto err;
 	ret = read(fd, ptr, sbuf.st_size);
tools/image-host.c +2 -1
index 46036673050..3974ee3d389 100644
@@ -167,7 +167,8 @@ static int fit_image_write_sig(void *fit, int noffset, uint8_t *value,
 		}
 	}
 	if (algo_name && !ret)
-		ret = fdt_setprop_string(fit, noffset, "algo", algo_name);
+		ret = fdt_setprop_string(fit, noffset, FIT_ALGO_PROP,
+					 algo_name);
 
 	return ret;
 }
Signature · 1 line
2.43.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH v1 1/3] tools: mkimage: use constants for FIT property names

Hi Aristo,

Quoted 9 lines · Aristo Chen

include/image.h defines constants for the FIT property names, but mkimage still spells out two of them as string literals.

When the signing algorithm is given with -o, fit_image_write_sig() records it in the "algo" property of the signature node using a literal, while fit_image_hash_get_algo(), which mkimage and the verification code use to read that property, uses FIT_ALGO_PROP. Use the constant for the write as well.

Quoted 6 lines

fdt_property_file() takes the property name as an argument but ignores it and always writes "data". Every caller passes FIT_DATA_PROP, so use the argument.

No functional change.

Considering there's a small trick for one the changes, maybe separate commits would have been better, but in any case:

Thanks!
Quentin

#3 lore raw

PATCH 2/3 boot: fit: use constants for FIT property names

In reply to Aristo Chen

Commit 634dcda25924 ("boot/fit: use constants for property strings") switched boot/common_fit.c and boot/image-fit.c to the property name constants in include/image.h, but a few literals are left in boot/:

- fdt_offset() in boot_fit.c reads "data-offset" and "data-size" from the FDT image node; use FIT_DATA_OFFSET_PROP and FIT_DATA_SIZE_PROP.
- boot_get_fpga() reads the "compatible" property of the FPGA image node. Commit 3059eb0c27dd ("boot/fit: declare (and use) new constant for conf's compatible prop") added FIT_COMPAT_PROP and noted that FPGA image nodes carry the same property; use it there too.
- fit_image_load_storage() looks up the dm-verity subnode by a literal name; use FIT_VERITY_NODENAME like the rest of the dm-verity code.

No functional change.

---
 boot/boot_fit.c    | 4 ++--
 boot/image-board.c | 3 ++-
 boot/image-fit.c   | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)
boot/boot_fit.c +2 -2
index 4dcaf95c6ae..aa867fe823f 100644
@@ -41,12 +41,12 @@ static int fdt_offset(const void *fit)
 		return -EINVAL;
 	}
 
-	fdt_offset = fdt_getprop_u32(fit, fdt_node, "data-offset");
+	fdt_offset = fdt_getprop_u32(fit, fdt_node, FIT_DATA_OFFSET_PROP);
 
 	if (fdt_offset == FDT_ERROR)
 		return -ENOENT;
 
-	fdt_len = fdt_getprop_u32(fit, fdt_node, "data-size");
+	fdt_len = fdt_getprop_u32(fit, fdt_node, FIT_DATA_SIZE_PROP);
 
 	if (fdt_len < 0)
 		return fdt_len;
boot/image-board.c +2 -1
index 67938fdd200..7602f5bfaaa 100644
@@ -685,7 +685,8 @@ int boot_get_fpga(struct bootm_headers *images)
 		}
 
 		conf_noffset = fit_image_get_node(buf, uname);
-		compatible = fdt_getprop(buf, conf_noffset, "compatible", NULL);
+		compatible = fdt_getprop(buf, conf_noffset, FIT_COMPAT_PROP,
+					 NULL);
 		if (!compatible) {
 			printf("'fpga' image without 'compatible' property\n");
 		} else {
boot/image-fit.c +2 -1
index 60e47db5fb0..e173108033b 100644
@@ -2196,7 +2196,8 @@ static int fit_image_load_storage(struct bootm_headers *images, const void *fit,
 
 		if (!fit_image_get_type(fit, noffset, &img_type) &&
 		    img_type == IH_TYPE_FILESYSTEM &&
-		    fdt_subnode_offset(fit, noffset, "dm-verity") >= 0) {
+		    fdt_subnode_offset(fit, noffset,
+				       FIT_VERITY_NODENAME) >= 0) {
 			fit_image_print(fit, noffset, "   ");
 			*datap = 0;
 			*lenp = 0;
Signature · 1 line
2.43.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH v1 2/3] boot: fit: use constants for FIT property names

Hi Aristo,

Quoted 13 lines · Aristo Chen

Commit 634dcda25924 ("boot/fit: use constants for property strings") switched boot/common_fit.c and boot/image-fit.c to the property name constants in include/image.h, but a few literals are left in boot/:

- fdt_offset() in boot_fit.c reads "data-offset" and "data-size" from the FDT image node; use FIT_DATA_OFFSET_PROP and FIT_DATA_SIZE_PROP.
- boot_get_fpga() reads the "compatible" property of the FPGA image node. Commit 3059eb0c27dd ("boot/fit: declare (and use) new constant for conf's compatible prop") added FIT_COMPAT_PROP and noted that FPGA image nodes carry the same property; use it there too.
- fit_image_load_storage() looks up the dm-verity subnode by a literal name; use FIT_VERITY_NODENAME like the rest of the dm-verity code.

Quoted 2 lines

No functional change.

Thanks!
Quentin

#5 lore raw

PATCH 3/3 spl: fit: use constants for FIT property names

In reply to Aristo Chen

spl_fit.c mostly uses the property name constants from include/image.h, including FIT_LOADABLE_PROP in spl_load_fit_image(), but still spells out a few names as literals:

- "loadables" in spl_fit_record_loadable() and spl_load_simple_fit(); use FIT_LOADABLE_PROP.
- "fpga" in spl_fit_load_fpga(); use FIT_FPGA_PROP.
- "compatible" of the FPGA image node in spl_fit_upload_fpga(); use FIT_COMPAT_PROP, as boot_get_fpga() does in U-Boot proper.

No functional change.

---
 common/spl/spl_fit.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
common/spl/spl_fit.c +6 -6
index 1a0066c92a0..64e5f95546f 100644
@@ -608,11 +608,11 @@ static int spl_fit_record_loadable(const struct spl_fit_info *ctx, int index,
 	const char *name;
 	int node;
 
-	ret = spl_fit_get_image_name(ctx, "loadables", index, &name);
+	ret = spl_fit_get_image_name(ctx, FIT_LOADABLE_PROP, index, &name);
 	if (ret < 0)
 		return ret;
 
-	node = spl_fit_get_image_node(ctx, "loadables", index);
+	node = spl_fit_get_image_node(ctx, FIT_LOADABLE_PROP, index);
 
 	ret = fdt_record_loadable(blob, index, name, image->load_addr,
 			image->size, image->entry_point,
@@ -735,7 +735,7 @@ static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node,
 	debug("FPGA bitstream at: %x, size: %x\n",
 	      (u32)fpga_image->load_addr, fpga_image->size);
 
-	compatible = fdt_getprop(ctx->fit, node, "compatible", NULL);
+	compatible = fdt_getprop(ctx->fit, node, FIT_COMPAT_PROP, NULL);
 	if (!compatible) {
 		warn_deprecated("'fpga' image without 'compatible' property");
 	} else {
@@ -767,7 +767,7 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx,
 		.load_addr = 0,
 	};
 
-	node = spl_fit_get_image_node(ctx, "fpga", 0);
+	node = spl_fit_get_image_node(ctx, FIT_FPGA_PROP, 0);
 	if (node < 0)
 		return node;
 
@@ -928,7 +928,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 
 	if (node < 0) {
 		debug("could not find firmware image, trying loadables...\n");
-		node = spl_fit_get_image_node(&ctx, "loadables", 0);
+		node = spl_fit_get_image_node(&ctx, FIT_LOADABLE_PROP, 0);
 		/*
 		 * If we pick the U-Boot image from "loadables", start at
 		 * the second image when later loading additional images.
@@ -971,7 +971,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	for (; ; index++) {
 		uint8_t os_type = IH_OS_INVALID;
 
-		node = spl_fit_get_image_node(&ctx, "loadables", index);
+		node = spl_fit_get_image_node(&ctx, FIT_LOADABLE_PROP, index);
 		if (node < 0)
 			break;
 
Signature · 1 line
2.43.0
Reviewed-by on v1 3/3
#6 lore raw

Re: [PATCH v1 3/3] spl: fit: use constants for FIT property names

Hi Aristo,

Quoted 4 lines · Aristo Chen

spl_fit.c mostly uses the property name constants from include/image.h, including FIT_LOADABLE_PROP in spl_load_fit_image(), but still spells out a few names as literals:

Quoted 8 lines

- "loadables" in spl_fit_record_loadable() and spl_load_simple_fit(); use FIT_LOADABLE_PROP.
- "fpga" in spl_fit_load_fpga(); use FIT_FPGA_PROP.
- "compatible" of the FPGA image node in spl_fit_upload_fpga(); use FIT_COMPAT_PROP, as boot_get_fpga() does in U-Boot proper.

No functional change.

Thanks!
Quentin

#7 lore raw

v2 cover fit: use constants for property names in mkimage, boot and SPL

In reply to Aristo Chen

include/image.h defines constants for the FIT property and node names, and most of the FIT code uses them, but mkimage, boot/ and the SPL FIT loader still spell a few of the names out as string literals. This series converts the remaining ones in those three areas: mkimage in patches 1 and 2, boot/ in patch 3 and SPL in patch 4.

Most of the changes swap a literal for the matching constant. Two need a word of explanation. fdt_property_file() in mkimage already takes the property name as an argument but ignores it and hardcodes "data", so patch 2 uses the argument; every caller passes FIT_DATA_PROP. FIT_COMPAT_PROP was added for the compatible property of configuration nodes by commit 3059eb0c27dd ("boot/fit: declare (and use) new constant for conf's compatible prop"), which noted that the same property can appear in FPGA image nodes but did not convert those. Patches 3 and 4 use FIT_COMPAT_PROP for the FPGA image node as well, in U-Boot proper and in SPL.

No functional change is intended. Built for sandbox, sandbox_spl and dra7xx_evm (U-Boot proper, SPL and host tools), the objects of all touched files are identical before and after the series once debug info is stripped and the embedded version string is held fixed. The only exception is four __LINE__ values in boot/image-fit.c log calls, which move down by one where patch 3 wraps a line. Each patch builds for those three boards, and the sandbox FIT, vboot, mkimage and dm-verity pytests pass.

The series is based on next, where the dm-verity code touched by patch 3 lives.

Link to v1:
https://lore.kernel.org/u-boot/[email protected]/

Changes in v2:
- Split v1 patch 1 in two, so that the fdt_property_file() change, which is not a plain constant swap, is a patch of its own (Quentin)
- No code changes; collected Quentin's Reviewed-by on all patches, carried over to both halves of the split patch

Aristo Chen (4):
tools: mkimage: use FIT_ALGO_PROP for the signature algo property
tools: mkimage: use the name argument in fdt_property_file()
boot: fit: use constants for FIT property names
spl: fit: use constants for FIT property names

 boot/boot_fit.c      |  4 ++--
 boot/image-board.c   |  3 ++-
 boot/image-fit.c     |  3 ++-
 common/spl/spl_fit.c | 12 ++++++------
 tools/fit_image.c    |  2 +-
 tools/image-host.c   |  3 ++-
 6 files changed, 15 insertions(+), 12 deletions(-)
Signature · 1 line
2.43.0
#8 lore raw

PATCH v2 1/4 tools: mkimage: use FIT_ALGO_PROP for the signature algo property

When the signing algorithm is given with -o, fit_image_write_sig() records it in the "algo" property of the signature node using a string literal, while fit_image_hash_get_algo(), which mkimage and the verification code use to read that property, uses FIT_ALGO_PROP. Use the constant for the write as well.

No functional change.

---
v2: split out of v1 patch 1, no code changes, Reviewed-by from v1 patch 1 kept

 tools/image-host.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
tools/image-host.c +2 -1
index 46036673050..3974ee3d389 100644
@@ -167,7 +167,8 @@ static int fit_image_write_sig(void *fit, int noffset, uint8_t *value,
 		}
 	}
 	if (algo_name && !ret)
-		ret = fdt_setprop_string(fit, noffset, "algo", algo_name);
+		ret = fdt_setprop_string(fit, noffset, FIT_ALGO_PROP,
+					 algo_name);
 
 	return ret;
 }
Signature · 1 line
2.43.0
Reviewed-by on v2 1/4
#9 lore raw

Re: [PATCH v2 1/4] tools: mkimage: use FIT_ALGO_PROP for the signature algo property

Quoted 8 lines · Aristo Chen

tools: mkimage: use FIT_ALGO_PROP for the signature algo property

When the signing algorithm is given with -o, fit_image_write_sig() records it in the "algo" property of the signature node using a string literal, while fit_image_hash_get_algo(), which mkimage and the verification code use to read that property, uses FIT_ALGO_PROP. Use the constant for the write as well.

Quoted 7 lines

No functional change.

tools/image-host.c | 3 ++-

 1 file changed, 2 insertions(+), 1 deletion(-)
#10 lore raw

PATCH v2 2/4 tools: mkimage: use the name argument in fdt_property_file()

In reply to Aristo Chen

fdt_property_file() takes the property name as an argument but ignores it and always writes a literal "data" property. Every caller passes FIT_DATA_PROP, so use the argument.

No functional change.

---
v2: new patch, split out of v1 patch 1 as suggested by Quentin, no code changes, Reviewed-by from v1 patch 1 kept

 tools/fit_image.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/fit_image.c +1 -1
index f7d11904472..077906889ca 100644
@@ -250,7 +250,7 @@ static int fdt_property_file(struct image_tool_params *params,
 		goto err;
 	}
 
-	ret = fdt_property_placeholder(fdt, "data", sbuf.st_size, &ptr);
+	ret = fdt_property_placeholder(fdt, name, sbuf.st_size, &ptr);
 	if (ret)
 		goto err;
 	ret = read(fd, ptr, sbuf.st_size);
Signature · 1 line
2.43.0
Reviewed-by on v2 2/4
#11 lore raw

Re: [PATCH v2 2/4] tools: mkimage: use the name argument in fdt_property_file()

Quoted 6 lines · Aristo Chen

tools: mkimage: use the name argument in fdt_property_file()

fdt_property_file() takes the property name as an argument but ignores it and always writes a literal "data" property. Every caller passes FIT_DATA_PROP, so use the argument.

Quoted 7 lines

No functional change.

tools/fit_image.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
#12 lore raw

PATCH v2 3/4 boot: fit: use constants for FIT property names

In reply to Aristo Chen

Commit 634dcda25924 ("boot/fit: use constants for property strings") switched boot/common_fit.c and boot/image-fit.c to the property name constants in include/image.h, but a few literals are left in boot/:

- fdt_offset() in boot_fit.c reads "data-offset" and "data-size" from the FDT image node; use FIT_DATA_OFFSET_PROP and FIT_DATA_SIZE_PROP.
- boot_get_fpga() reads the "compatible" property of the FPGA image node. Commit 3059eb0c27dd ("boot/fit: declare (and use) new constant for conf's compatible prop") added FIT_COMPAT_PROP and noted that FPGA image nodes carry the same property; use it there too.
- fit_image_load_storage() looks up the dm-verity subnode by a literal name; use FIT_VERITY_NODENAME like the rest of the dm-verity code.

No functional change.

---
v2: no code changes, collected Reviewed-by

 boot/boot_fit.c    | 4 ++--
 boot/image-board.c | 3 ++-
 boot/image-fit.c   | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)
boot/boot_fit.c +2 -2
index 4dcaf95c6ae..aa867fe823f 100644
@@ -41,12 +41,12 @@ static int fdt_offset(const void *fit)
 		return -EINVAL;
 	}
 
-	fdt_offset = fdt_getprop_u32(fit, fdt_node, "data-offset");
+	fdt_offset = fdt_getprop_u32(fit, fdt_node, FIT_DATA_OFFSET_PROP);
 
 	if (fdt_offset == FDT_ERROR)
 		return -ENOENT;
 
-	fdt_len = fdt_getprop_u32(fit, fdt_node, "data-size");
+	fdt_len = fdt_getprop_u32(fit, fdt_node, FIT_DATA_SIZE_PROP);
 
 	if (fdt_len < 0)
 		return fdt_len;
boot/image-board.c +2 -1
index 67938fdd200..7602f5bfaaa 100644
@@ -685,7 +685,8 @@ int boot_get_fpga(struct bootm_headers *images)
 		}
 
 		conf_noffset = fit_image_get_node(buf, uname);
-		compatible = fdt_getprop(buf, conf_noffset, "compatible", NULL);
+		compatible = fdt_getprop(buf, conf_noffset, FIT_COMPAT_PROP,
+					 NULL);
 		if (!compatible) {
 			printf("'fpga' image without 'compatible' property\n");
 		} else {
boot/image-fit.c +2 -1
index 60e47db5fb0..e173108033b 100644
@@ -2196,7 +2196,8 @@ static int fit_image_load_storage(struct bootm_headers *images, const void *fit,
 
 		if (!fit_image_get_type(fit, noffset, &img_type) &&
 		    img_type == IH_TYPE_FILESYSTEM &&
-		    fdt_subnode_offset(fit, noffset, "dm-verity") >= 0) {
+		    fdt_subnode_offset(fit, noffset,
+				       FIT_VERITY_NODENAME) >= 0) {
 			fit_image_print(fit, noffset, "   ");
 			*datap = 0;
 			*lenp = 0;
Signature · 1 line
2.43.0
Reviewed-by on v2 3/4
#13 lore raw

Re: [PATCH v2 3/4] boot: fit: use constants for FIT property names

Quoted 17 lines · Aristo Chen

boot: fit: use constants for FIT property names

Commit 634dcda25924 ("boot/fit: use constants for property strings") switched boot/common_fit.c and boot/image-fit.c to the property name constants in include/image.h, but a few literals are left in boot/:

- fdt_offset() in boot_fit.c reads "data-offset" and "data-size" from the FDT image node; use FIT_DATA_OFFSET_PROP and FIT_DATA_SIZE_PROP.
- boot_get_fpga() reads the "compatible" property of the FPGA image node. Commit 3059eb0c27dd ("boot/fit: declare (and use) new constant for conf's compatible prop") added FIT_COMPAT_PROP and noted that FPGA image nodes carry the same property; use it there too.
- fit_image_load_storage() looks up the dm-verity subnode by a literal name; use FIT_VERITY_NODENAME like the rest of the dm-verity code.

No functional change.

Quoted 7 lines

boot/boot_fit.c | 4 ++--

 boot/image-board.c | 3 ++-
 boot/image-fit.c   | 3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)
#14 lore raw

PATCH v2 4/4 spl: fit: use constants for FIT property names

In reply to Aristo Chen

spl_fit.c mostly uses the property name constants from include/image.h, including FIT_LOADABLE_PROP in spl_load_fit_image(), but still spells out a few names as literals:

- "loadables" in spl_fit_record_loadable() and spl_load_simple_fit(); use FIT_LOADABLE_PROP.
- "fpga" in spl_fit_load_fpga(); use FIT_FPGA_PROP.
- "compatible" of the FPGA image node in spl_fit_upload_fpga(); use FIT_COMPAT_PROP, as boot_get_fpga() does in U-Boot proper.

No functional change.

---
v2: no code changes, collected Reviewed-by

 common/spl/spl_fit.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)
common/spl/spl_fit.c +6 -6
index 1a0066c92a0..64e5f95546f 100644
@@ -608,11 +608,11 @@ static int spl_fit_record_loadable(const struct spl_fit_info *ctx, int index,
 	const char *name;
 	int node;
 
-	ret = spl_fit_get_image_name(ctx, "loadables", index, &name);
+	ret = spl_fit_get_image_name(ctx, FIT_LOADABLE_PROP, index, &name);
 	if (ret < 0)
 		return ret;
 
-	node = spl_fit_get_image_node(ctx, "loadables", index);
+	node = spl_fit_get_image_node(ctx, FIT_LOADABLE_PROP, index);
 
 	ret = fdt_record_loadable(blob, index, name, image->load_addr,
 			image->size, image->entry_point,
@@ -735,7 +735,7 @@ static int spl_fit_upload_fpga(struct spl_fit_info *ctx, int node,
 	debug("FPGA bitstream at: %x, size: %x\n",
 	      (u32)fpga_image->load_addr, fpga_image->size);
 
-	compatible = fdt_getprop(ctx->fit, node, "compatible", NULL);
+	compatible = fdt_getprop(ctx->fit, node, FIT_COMPAT_PROP, NULL);
 	if (!compatible) {
 		warn_deprecated("'fpga' image without 'compatible' property");
 	} else {
@@ -767,7 +767,7 @@ static int spl_fit_load_fpga(struct spl_fit_info *ctx,
 		.load_addr = 0,
 	};
 
-	node = spl_fit_get_image_node(ctx, "fpga", 0);
+	node = spl_fit_get_image_node(ctx, FIT_FPGA_PROP, 0);
 	if (node < 0)
 		return node;
 
@@ -928,7 +928,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 
 	if (node < 0) {
 		debug("could not find firmware image, trying loadables...\n");
-		node = spl_fit_get_image_node(&ctx, "loadables", 0);
+		node = spl_fit_get_image_node(&ctx, FIT_LOADABLE_PROP, 0);
 		/*
 		 * If we pick the U-Boot image from "loadables", start at
 		 * the second image when later loading additional images.
@@ -971,7 +971,7 @@ int spl_load_simple_fit(struct spl_image_info *spl_image,
 	for (; ; index++) {
 		uint8_t os_type = IH_OS_INVALID;
 
-		node = spl_fit_get_image_node(&ctx, "loadables", index);
+		node = spl_fit_get_image_node(&ctx, FIT_LOADABLE_PROP, index);
 		if (node < 0)
 			break;
 
Signature · 1 line
2.43.0
Reviewed-by on v2 4/4
#15 lore raw

Re: [PATCH v2 4/4] spl: fit: use constants for FIT property names

Quoted 12 lines · Aristo Chen

spl: fit: use constants for FIT property names

spl_fit.c mostly uses the property name constants from include/image.h, including FIT_LOADABLE_PROP in spl_load_fit_image(), but still spells out a few names as literals:

- "loadables" in spl_fit_record_loadable() and spl_load_simple_fit(); use FIT_LOADABLE_PROP.
- "fpga" in spl_fit_load_fpga(); use FIT_FPGA_PROP.
- "compatible" of the FPGA image node in spl_fit_upload_fpga(); use FIT_COMPAT_PROP, as boot_get_fpga() does in U-Boot proper.

Quoted 7 lines

No functional change.

common/spl/spl_fit.c | 12 ++++++------

 1 file changed, 6 insertions(+), 6 deletions(-)
#16 lore raw
In reply to Aristo Chen
Quoted 17 lines · Aristo Chen

include/image.h defines constants for the FIT property and node names, and most of the FIT code uses them, but mkimage, boot/ and the SPL FIT loader still spell a few of the names out as string literals. This series converts the remaining ones in those three areas: mkimage in patches 1 and 2, boot/ in patch 3 and SPL in patch 4.

Most of the changes swap a literal for the matching constant. Two need a word of explanation. fdt_property_file() in mkimage already takes the property name as an argument but ignores it and hardcodes "data", so patch 2 uses the argument; every caller passes FIT_DATA_PROP. FIT_COMPAT_PROP was added for the compatible property of configuration nodes by commit 3059eb0c27dd ("boot/fit: declare (and use) new constant for conf's compatible prop"), which noted that the same property can appear in FPGA image nodes but did not convert those. Patches 3 and 4 use FIT_COMPAT_PROP for the FPGA image node as well, in U-Boot proper and in SPL.

Quoted 1 line

[...]

Applied to u-boot/main, thanks!

[1/4] tools: mkimage: use FIT_ALGO_PROP for the signature algo property

      commit: 62ed983dad41c5515dfa0a222167a7a1d32955a4
[2/4] tools: mkimage: use the name argument in fdt_property_file()
      commit: 3ebc4ef7255f39c8a27e130f3a86c34bfda829bb
[3/4] boot: fit: use constants for FIT property names
      commit: fa2737df23f696b4919bf46dd01bb4b6191e3647
[4/4] spl: fit: use constants for FIT property names
      commit: ab0b18fc5697117b8bcd9b5afd740f34bbe031c2
Signature · 1 line
Tom