All of lore.kernel.org
 help / color / mirror / Atom feed
From: Michal Simek <michal.simek@xilinx.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH] mkimage: fit_image: Use macros from image.h
Date: Fri, 20 Jul 2018 12:31:02 +0200	[thread overview]
Message-ID: <8047e2ecc83d516b32dd9e6c6ea8a05e64f15500.1532082660.git.michal.simek@xilinx.com> (raw)

There is no reason not to use macros which are already defined.
It is also much easier for grepping.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

 tools/fit_image.c | 53 +++++++++++++++++++++++++++++------------------------
 1 file changed, 29 insertions(+), 24 deletions(-)

diff --git a/tools/fit_image.c b/tools/fit_image.c
index 3c265357ae73..4b626354fb3f 100644
--- a/tools/fit_image.c
+++ b/tools/fit_image.c
@@ -202,21 +202,22 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
 	typename = genimg_get_type_short_name(params->fit_image_type);
 	snprintf(str, sizeof(str), "%s-1", typename);
 	fdt_begin_node(fdt, str);
-	fdt_property_string(fdt, "description", params->imagename);
-	fdt_property_string(fdt, "type", typename);
-	fdt_property_string(fdt, "arch",
+	fdt_property_string(fdt, FIT_DESC_PROP, params->imagename);
+	fdt_property_string(fdt, FIT_TYPE_PROP, typename);
+	fdt_property_string(fdt, FIT_ARCH_PROP,
 			    genimg_get_arch_short_name(params->arch));
-	fdt_property_string(fdt, "os", genimg_get_os_short_name(params->os));
-	fdt_property_string(fdt, "compression",
+	fdt_property_string(fdt, FIT_OS_PROP,
+			    genimg_get_os_short_name(params->os));
+	fdt_property_string(fdt, FIT_COMP_PROP,
 			    genimg_get_comp_short_name(params->comp));
-	fdt_property_u32(fdt, "load", params->addr);
-	fdt_property_u32(fdt, "entry", params->ep);
+	fdt_property_u32(fdt, FIT_LOAD_PROP, params->addr);
+	fdt_property_u32(fdt, FIT_ENTRY_PROP, params->ep);
 
 	/*
 	 * Put data last since it is large. SPL may only load the first part
 	 * of the DT, so this way it can access all the above fields.
 	 */
-	ret = fdt_property_file(params, fdt, "data", params->datafile);
+	ret = fdt_property_file(params, fdt, FIT_DATA_PROP, params->datafile);
 	if (ret)
 		return ret;
 	fdt_end_node(fdt);
@@ -230,14 +231,15 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
 		fdt_begin_node(fdt, str);
 
 		get_basename(str, sizeof(str), cont->fname);
-		fdt_property_string(fdt, "description", str);
-		ret = fdt_property_file(params, fdt, "data", cont->fname);
+		fdt_property_string(fdt, FIT_DESC_PROP, str);
+		ret = fdt_property_file(params, fdt, FIT_DATA_PROP,
+					cont->fname);
 		if (ret)
 			return ret;
-		fdt_property_string(fdt, "type", typename);
-		fdt_property_string(fdt, "arch",
+		fdt_property_string(fdt, FIT_TYPE_PROP, typename);
+		fdt_property_string(fdt, FIT_ARCH_PROP,
 				    genimg_get_arch_short_name(params->arch));
-		fdt_property_string(fdt, "compression",
+		fdt_property_string(fdt, FIT_COMP_PROP,
 				    genimg_get_comp_short_name(IH_COMP_NONE));
 		fdt_end_node(fdt);
 	}
@@ -246,10 +248,12 @@ static int fit_write_images(struct image_tool_params *params, char *fdt)
 	if (params->fit_ramdisk) {
 		fdt_begin_node(fdt, FIT_RAMDISK_PROP "-1");
 
-		fdt_property_string(fdt, "type", FIT_RAMDISK_PROP);
-		fdt_property_string(fdt, "os", genimg_get_os_short_name(params->os));
+		fdt_property_string(fdt, FIT_TYPE_PROP, FIT_RAMDISK_PROP);
+		fdt_property_string(fdt, FIT_OS_PROP,
+				    genimg_get_os_short_name(params->os));
 
-		ret = fdt_property_file(params, fdt, "data", params->fit_ramdisk);
+		ret = fdt_property_file(params, fdt, FIT_DATA_PROP,
+					params->fit_ramdisk);
 		if (ret)
 			return ret;
 
@@ -278,7 +282,7 @@ static void fit_write_configs(struct image_tool_params *params, char *fdt)
 	int upto;
 
 	fdt_begin_node(fdt, "configurations");
-	fdt_property_string(fdt, "default", "conf-1");
+	fdt_property_string(fdt, FIT_DEFAULT_PROP, "conf-1");
 
 	upto = 0;
 	for (cont = params->content_head; cont; cont = cont->next) {
@@ -289,7 +293,7 @@ static void fit_write_configs(struct image_tool_params *params, char *fdt)
 		fdt_begin_node(fdt, str);
 
 		get_basename(str, sizeof(str), cont->fname);
-		fdt_property_string(fdt, "description", str);
+		fdt_property_string(fdt, FIT_DESC_PROP, str);
 
 		typename = genimg_get_type_short_name(params->fit_image_type);
 		snprintf(str, sizeof(str), "%s-1", typename);
@@ -329,7 +333,7 @@ static int fit_build_fdt(struct image_tool_params *params, char *fdt, int size)
 		return ret;
 	fdt_finish_reservemap(fdt);
 	fdt_begin_node(fdt, "");
-	fdt_property_strf(fdt, "description",
+	fdt_property_strf(fdt, FIT_DESC_PROP,
 			  "%s image with one or more FDT blobs",
 			  genimg_get_type_name(params->fit_image_type));
 	fdt_property_strf(fdt, "creator", "U-Boot mkimage %s", PLAIN_VERSION);
@@ -441,25 +445,26 @@ static int fit_extract_data(struct image_tool_params *params, const char *fname)
 		const char *data;
 		int len;
 
-		data = fdt_getprop(fdt, node, "data", &len);
+		data = fdt_getprop(fdt, node, FIT_DATA_PROP, &len);
 		if (!data)
 			continue;
 		memcpy(buf + buf_ptr, data, len);
 		debug("Extracting data size %x\n", len);
 
-		ret = fdt_delprop(fdt, node, "data");
+		ret = fdt_delprop(fdt, node, FIT_DATA_PROP);
 		if (ret) {
 			ret = -EPERM;
 			goto err_munmap;
 		}
 		if (params->external_offset > 0) {
 			/* An external offset positions the data absolutely. */
-			fdt_setprop_u32(fdt, node, "data-position",
+			fdt_setprop_u32(fdt, node, FIT_DATA_POSITION_PROP,
 					params->external_offset + buf_ptr);
 		} else {
-			fdt_setprop_u32(fdt, node, "data-offset", buf_ptr);
+			fdt_setprop_u32(fdt, node, FIT_DATA_OFFSET_PROP,
+					buf_ptr);
 		}
-		fdt_setprop_u32(fdt, node, "data-size", len);
+		fdt_setprop_u32(fdt, node, FIT_DATA_SIZE_PROP, len);
 
 		buf_ptr += (len + 3) & ~3;
 	}
-- 
1.9.1

             reply	other threads:[~2018-07-20 10:31 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-20 10:31 Michal Simek [this message]
2018-07-23 23:48 ` [U-Boot] [PATCH] mkimage: fit_image: Use macros from image.h Simon Glass
2018-07-26 19:54 ` [U-Boot] " Tom Rini

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8047e2ecc83d516b32dd9e6c6ea8a05e64f15500.1532082660.git.michal.simek@xilinx.com \
    --to=michal.simek@xilinx.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.