bootm: Use print_decomp_msg() in all cases

Refactor to allow this function to be used to announce the image being
loaded regardless of compression type and even when there is no
decompression.

Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/common/bootm.c b/common/bootm.c
index 10c15ef..4a5c5ea 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -266,13 +266,25 @@
 }
 #endif /* USE_HOSTC */
 
-#if defined(CONFIG_GZIP) || defined(CONFIG_GZIP) || defined(CONFIG_BZIP2) || \
-	defined(CONFIG_LZMA) || defined(CONFIG_LZO)
-static void print_decomp_msg(const char *type_name)
+/**
+ * print_decomp_msg() - Print a suitable decompression/loading message
+ *
+ * @type:	OS type (IH_OS_...)
+ * @comp_type:	Compression type being used (IH_COMP_...)
+ * @is_xip:	true if the load address matches the image start
+ */
+static void print_decomp_msg(int comp_type, int type, bool is_xip)
 {
-	printf("   Uncompressing %s ... ", type_name);
+	const char *name = genimg_get_type_name(type);
+
+	if (comp_type == IH_COMP_NONE)
+		printf("   %s %s ... ", is_xip ? "XIP" : "Loading", name);
+	else
+		printf("   Uncompressing %s ... ", name);
 }
 
+#if defined(CONFIG_GZIP) || defined(CONFIG_GZIP) || defined(CONFIG_BZIP2) || \
+	defined(CONFIG_LZMA) || defined(CONFIG_LZO)
 static int handle_decomp_error(const char *algo, size_t size, size_t unc_len,
 			       int ret)
 {
@@ -293,24 +305,18 @@
 		       void *load_buf, void *image_buf, ulong image_len,
 		       uint unc_len, ulong *load_end)
 {
-	const char *type_name = genimg_get_type_name(type);
-
 	*load_end = load;
+	print_decomp_msg(comp, type, load == image_start);
 	switch (comp) {
 	case IH_COMP_NONE:
-		if (load == image_start) {
-			printf("   XIP %s ... ", type_name);
-		} else {
-			printf("   Loading %s ... ", type_name);
+		if (load != image_start)
 			memmove_wd(load_buf, image_buf, image_len, CHUNKSZ);
-		}
 		*load_end = load + image_len;
 		break;
 #ifdef CONFIG_GZIP
 	case IH_COMP_GZIP: {
 		int ret;
 
-		print_decomp_msg(type_name);
 		ret = gunzip(load_buf, unc_len, image_buf, &image_len);
 		if (ret != 0) {
 			return handle_decomp_error("GUNZIP", image_len,
@@ -325,7 +331,6 @@
 	case IH_COMP_BZIP2: {
 		size_t size = unc_len;
 
-		print_decomp_msg(type_name);
 		/*
 		 * If we've got less than 4 MB of malloc() space,
 		 * use slower decompression algorithm which requires
@@ -348,7 +353,6 @@
 		SizeT lzma_len = unc_len;
 		int ret;
 
-		print_decomp_msg(type_name);
 		ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
 					       image_buf, image_len);
 		if (ret != SZ_OK) {
@@ -365,8 +369,6 @@
 		size_t size = unc_len;
 		int ret;
 
-		print_decomp_msg(type_name);
-
 		ret = lzop_decompress(image_buf, image_len, load_buf, &size);
 		if (ret != LZO_E_OK)
 			return handle_decomp_error("LZO", size, unc_len, ret);