Commit 8fd6a4b514c9828f0c2de92f5c89a3c84458e13f

Authored by Simon Glass
Committed by Tom Rini
1 parent 6ed4dc7876

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>

Showing 1 changed file with 18 additions and 16 deletions Side-by-side Diff

... ... @@ -266,13 +266,25 @@
266 266 }
267 267 #endif /* USE_HOSTC */
268 268  
269   -#if defined(CONFIG_GZIP) || defined(CONFIG_GZIP) || defined(CONFIG_BZIP2) || \
270   - defined(CONFIG_LZMA) || defined(CONFIG_LZO)
271   -static void print_decomp_msg(const char *type_name)
  269 +/**
  270 + * print_decomp_msg() - Print a suitable decompression/loading message
  271 + *
  272 + * @type: OS type (IH_OS_...)
  273 + * @comp_type: Compression type being used (IH_COMP_...)
  274 + * @is_xip: true if the load address matches the image start
  275 + */
  276 +static void print_decomp_msg(int comp_type, int type, bool is_xip)
272 277 {
273   - printf(" Uncompressing %s ... ", type_name);
  278 + const char *name = genimg_get_type_name(type);
  279 +
  280 + if (comp_type == IH_COMP_NONE)
  281 + printf(" %s %s ... ", is_xip ? "XIP" : "Loading", name);
  282 + else
  283 + printf(" Uncompressing %s ... ", name);
274 284 }
275 285  
  286 +#if defined(CONFIG_GZIP) || defined(CONFIG_GZIP) || defined(CONFIG_BZIP2) || \
  287 + defined(CONFIG_LZMA) || defined(CONFIG_LZO)
276 288 static int handle_decomp_error(const char *algo, size_t size, size_t unc_len,
277 289 int ret)
278 290 {
279 291  
280 292  
281 293  
282 294  
... ... @@ -293,24 +305,18 @@
293 305 void *load_buf, void *image_buf, ulong image_len,
294 306 uint unc_len, ulong *load_end)
295 307 {
296   - const char *type_name = genimg_get_type_name(type);
297   -
298 308 *load_end = load;
  309 + print_decomp_msg(comp, type, load == image_start);
299 310 switch (comp) {
300 311 case IH_COMP_NONE:
301   - if (load == image_start) {
302   - printf(" XIP %s ... ", type_name);
303   - } else {
304   - printf(" Loading %s ... ", type_name);
  312 + if (load != image_start)
305 313 memmove_wd(load_buf, image_buf, image_len, CHUNKSZ);
306   - }
307 314 *load_end = load + image_len;
308 315 break;
309 316 #ifdef CONFIG_GZIP
310 317 case IH_COMP_GZIP: {
311 318 int ret;
312 319  
313   - print_decomp_msg(type_name);
314 320 ret = gunzip(load_buf, unc_len, image_buf, &image_len);
315 321 if (ret != 0) {
316 322 return handle_decomp_error("GUNZIP", image_len,
... ... @@ -325,7 +331,6 @@
325 331 case IH_COMP_BZIP2: {
326 332 size_t size = unc_len;
327 333  
328   - print_decomp_msg(type_name);
329 334 /*
330 335 * If we've got less than 4 MB of malloc() space,
331 336 * use slower decompression algorithm which requires
... ... @@ -348,7 +353,6 @@
348 353 SizeT lzma_len = unc_len;
349 354 int ret;
350 355  
351   - print_decomp_msg(type_name);
352 356 ret = lzmaBuffToBuffDecompress(load_buf, &lzma_len,
353 357 image_buf, image_len);
354 358 if (ret != SZ_OK) {
... ... @@ -364,8 +368,6 @@
364 368 case IH_COMP_LZO: {
365 369 size_t size = unc_len;
366 370 int ret;
367   -
368   - print_decomp_msg(type_name);
369 371  
370 372 ret = lzop_decompress(image_buf, image_len, load_buf, &size);
371 373 if (ret != LZO_E_OK)