mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-29 08:00:26 +09:00
zlib/gunzip: Use WATCHDOG_RESET macro
As usually done in U-Boot, the watchdog_reset code is called via a macro (WATCHDOG_RESET). In zlib.c this was done differently, by using a function pointer which is initialized with WATCHDOG_RESET upon watchdog usage or with NULL otherwise. This patch now uses the plain WATCHDOG_RESET macros to call the function resulting in slightly smaller U-Boot images and simpler code. U-Boot code size reduction: PowerPC board with watchdog support (lwmon5): -> 80 bytes smaller image size PowerPC board without watchdog support (sequoia): -> 112 bytes smaller image size Signed-off-by: Stefan Roese <sr@denx.de> Cc: Detlev Zundel <dzu@denx.de> Cc: Wolfgang Denk <wd@denx.de> Acked-by: Detlev Zundel <dzu@denx.de>
This commit is contained in:
parent
6213b8ffa5
commit
f852628638
@ -96,11 +96,6 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
|
|||||||
|
|
||||||
s.zalloc = zalloc;
|
s.zalloc = zalloc;
|
||||||
s.zfree = zfree;
|
s.zfree = zfree;
|
||||||
#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
|
|
||||||
s.outcb = (cb_func)WATCHDOG_RESET;
|
|
||||||
#else
|
|
||||||
s.outcb = Z_NULL;
|
|
||||||
#endif /* CONFIG_HW_WATCHDOG */
|
|
||||||
|
|
||||||
r = inflateInit2(&s, -MAX_WBITS);
|
r = inflateInit2(&s, -MAX_WBITS);
|
||||||
if (r != Z_OK) {
|
if (r != Z_OK) {
|
||||||
|
10
lib/zlib.c
10
lib/zlib.c
@ -29,6 +29,7 @@
|
|||||||
#include <common.h>
|
#include <common.h>
|
||||||
#include <compiler.h>
|
#include <compiler.h>
|
||||||
#include <asm/unaligned.h>
|
#include <asm/unaligned.h>
|
||||||
|
#include <watchdog.h>
|
||||||
#include "u-boot/zlib.h"
|
#include "u-boot/zlib.h"
|
||||||
#undef OFF /* avoid conflicts */
|
#undef OFF /* avoid conflicts */
|
||||||
|
|
||||||
@ -1075,8 +1076,7 @@ z_streamp strm;
|
|||||||
state->hold = 0;
|
state->hold = 0;
|
||||||
state->bits = 0;
|
state->bits = 0;
|
||||||
state->lencode = state->distcode = state->next = state->codes;
|
state->lencode = state->distcode = state->next = state->codes;
|
||||||
if (strm->outcb != Z_NULL)
|
WATCHDOG_RESET();
|
||||||
(*strm->outcb)(Z_NULL, 0);
|
|
||||||
Tracev((stderr, "inflate: reset\n"));
|
Tracev((stderr, "inflate: reset\n"));
|
||||||
return Z_OK;
|
return Z_OK;
|
||||||
}
|
}
|
||||||
@ -1776,8 +1776,7 @@ int flush;
|
|||||||
Tracev((stderr, "inflate: codes ok\n"));
|
Tracev((stderr, "inflate: codes ok\n"));
|
||||||
state->mode = LEN;
|
state->mode = LEN;
|
||||||
case LEN:
|
case LEN:
|
||||||
if (strm->outcb != Z_NULL) /* for watchdog (U-Boot) */
|
WATCHDOG_RESET();
|
||||||
(*strm->outcb)(Z_NULL, 0);
|
|
||||||
if (have >= 6 && left >= 258) {
|
if (have >= 6 && left >= 258) {
|
||||||
RESTORE();
|
RESTORE();
|
||||||
inflate_fast(strm, out);
|
inflate_fast(strm, out);
|
||||||
@ -1990,8 +1989,7 @@ z_streamp strm;
|
|||||||
return Z_STREAM_ERROR;
|
return Z_STREAM_ERROR;
|
||||||
state = (struct inflate_state FAR *)strm->state;
|
state = (struct inflate_state FAR *)strm->state;
|
||||||
if (state->window != Z_NULL) {
|
if (state->window != Z_NULL) {
|
||||||
if (strm->outcb != Z_NULL)
|
WATCHDOG_RESET();
|
||||||
(*strm->outcb)(Z_NULL, 0);
|
|
||||||
ZFREE(strm, state->window);
|
ZFREE(strm, state->window);
|
||||||
}
|
}
|
||||||
ZFREE(strm, strm->state);
|
ZFREE(strm, strm->state);
|
||||||
|
Loading…
Reference in New Issue
Block a user