[PATCH 16/16] bootm: use generic uncompress function

Sascha Hauer s.hauer at pengutronix.de
Mon Nov 28 17:10:09 EST 2011


This simplifies the code somewhat. The user visible change here is
that we now ignore the compression specified in the uImage. Instead
we detect the compression type from the data which also means that
we now support lzo compressed uImages.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 commands/bootm.c |   31 ++++---------------------------
 1 files changed, 4 insertions(+), 27 deletions(-)

diff --git a/commands/bootm.c b/commands/bootm.c
index 878b7aa..b313cfc 100644
--- a/commands/bootm.c
+++ b/commands/bootm.c
@@ -30,7 +30,6 @@
 #include <command.h>
 #include <image.h>
 #include <malloc.h>
-#include <gunzip.h>
 #include <environment.h>
 #include <asm/byteorder.h>
 #include <xfuncs.h>
@@ -41,7 +40,7 @@
 #include <boot.h>
 #include <rtc.h>
 #include <init.h>
-#include <bunzip2.h>
+#include <uncompress.h>
 #include <asm-generic/memory_layout.h>
 
 /*
@@ -103,11 +102,6 @@ struct image_handle_data* image_handle_data_get_by_num(struct image_handle* hand
 	return &handle->data_entries[num];
 }
 
-static void unzip_error(char *x)
-{
-	puts(x);
-}
-
 int relocate_image(struct image_handle *handle, void *load_address)
 {
 	image_header_t *hdr = &handle->header;
@@ -131,30 +125,13 @@ int relocate_image(struct image_handle *handle, void *load_address)
 			memmove ((void *) image_get_load(hdr), (uchar *)data, len);
 		}
 		break;
-#ifdef CONFIG_ZLIB
-	case IH_COMP_GZIP:
-		printf ("   Uncompressing ... ");
-
-		ret = gunzip((void *)data, len, NULL, NULL, load_address, NULL,
-				unzip_error);
-		if (ret)
-			return ret;
-		break;
-#endif
-#ifdef CONFIG_BZLIB
-	case IH_COMP_BZIP2:
+	default:
 		printf ("   Uncompressing ... ");
-
-		ret = bunzip2((void *)data, len, NULL, NULL, load_address, NULL,
-				unzip_error);
+		ret = uncompress((void *)data, len, NULL, NULL, load_address, NULL,
+				uncompress_err_stdout);
 		if (ret)
 			return ret;
 		break;
-#endif
-	default:
-		printf("Unimplemented compression type %d\n",
-		       image_get_comp(hdr));
-		return -1;
 	}
 
 	return 0;
-- 
1.7.7.1




More information about the barebox mailing list