[PATCH 27/35] common: Rename and move source()

Simon Glass sjg at chromium.org
Thu Dec 12 01:47:46 CET 2019


This function has a very generic name which does not adequately describe
its purpose. Rename it and move it to image.h, since it relates to reading
a script from an image.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 cmd/source.c               |  5 ++---
 drivers/usb/gadget/f_sdp.c |  2 +-
 include/common.h           |  3 ---
 include/image.h            | 12 ++++++++++++
 4 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/cmd/source.c b/cmd/source.c
index be1135014f..92f8f77ee6 100644
--- a/cmd/source.c
+++ b/cmd/source.c
@@ -41,8 +41,7 @@ static const char *get_default_image(const void *fit)
 }
 #endif
 
-int
-source (ulong addr, const char *fit_uname)
+int image_source_script(ulong addr, const char *fit_uname)
 {
 	ulong		len;
 #if defined(CONFIG_LEGACY_IMAGE_FORMAT)
@@ -183,7 +182,7 @@ static int do_source(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
 	}
 
 	printf ("## Executing script at %08lx\n", addr);
-	rcode = source (addr, fit_uname);
+	rcode = image_source_script(addr, fit_uname);
 	return rcode;
 }
 
diff --git a/drivers/usb/gadget/f_sdp.c b/drivers/usb/gadget/f_sdp.c
index bcd1c5d47c..50836db4a0 100644
--- a/drivers/usb/gadget/f_sdp.c
+++ b/drivers/usb/gadget/f_sdp.c
@@ -726,7 +726,7 @@ static void sdp_handle_in_ep(struct spl_image_info *spl_image)
 			jump_to_image_no_args(&spl_image);
 #else
 			/* In U-Boot, allow jumps to scripts */
-			source(sdp_func->jmp_address, "script at 1");
+			image_source_script(sdp_func->jmp_address, "script at 1");
 #endif
 		}
 
diff --git a/include/common.h b/include/common.h
index 5e38c5fc58..c69bad9771 100644
--- a/include/common.h
+++ b/include/common.h
@@ -59,9 +59,6 @@ void	hang		(void) __attribute__ ((noreturn));
 
 #include <display_options.h>
 
-/* common/cmd_source.c */
-int	source (ulong addr, const char *fit_uname);
-
 /* common/memsize.c */
 long	get_ram_size  (long *, long);
 phys_size_t get_effective_memsize(void);
diff --git a/include/image.h b/include/image.h
index cc52de567b..80c0737463 100644
--- a/include/image.h
+++ b/include/image.h
@@ -673,6 +673,18 @@ int fit_image_load(bootm_headers_t *images, ulong addr,
 		   int arch, int image_type, int bootstage_id,
 		   enum fit_load_op load_op, ulong *datap, ulong *lenp);
 
+/**
+ * image_source_script() - Execute a script
+ *
+ * Executes a U-Boot script at a particular address in memory. The script should
+ * have a header (FIT or legacy) with the script type (IH_TYPE_SCRIPT).
+ *
+ * @addr: Address of script
+ * @fit_uname: FIT subimage name
+ * @return result code (enum command_ret_t)
+ */
+int image_source_script(ulong addr, const char *fit_uname);
+
 #ifndef USE_HOSTCC
 /**
  * fit_get_node_from_config() - Look up an image a FIT by type
-- 
2.24.0.525.g8f36a354ae-goog



More information about the U-Boot mailing list