diff options
author | Bartlomiej Sieka <tur@semihalf.com> | 2008-04-18 10:39:23 (GMT) |
---|---|---|
committer | Wolfgang Denk <wd@denx.de> | 2008-04-24 15:21:55 (GMT) |
commit | edbed247a14d70b94958010f736621212285de91 (patch) | |
tree | 9a12403755db2dfe959f5b0133b05bc69d0db4f5 /common | |
parent | 0a0b606faaec4afb3f750b09aa4df1e40a39dcb8 (diff) | |
download | u-boot-edbed247a14d70b94958010f736621212285de91.tar.xz |
Memory footprint optimizations
As suggested by Wolfgang Denk:
- image printing functions:
- remove wrappers
- remove indentation prefix from functions' signatures
- merge getenv_verify and getenv_autostart into one parametrized function
Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
Diffstat (limited to 'common')
-rw-r--r-- | common/cmd_autoscript.c | 2 | ||||
-rw-r--r-- | common/cmd_bootm.c | 4 | ||||
-rw-r--r-- | common/cmd_ximg.c | 2 | ||||
-rw-r--r-- | common/image.c | 56 |
4 files changed, 27 insertions, 37 deletions
diff --git a/common/cmd_autoscript.c b/common/cmd_autoscript.c index 1a37b90..932f638 100644 --- a/common/cmd_autoscript.c +++ b/common/cmd_autoscript.c @@ -65,7 +65,7 @@ autoscript (ulong addr, const char *fit_uname) size_t fit_len; #endif - verify = getenv_verify (); + verify = getenv_yesno ("verify"); switch (genimg_get_format ((void *)addr)) { case IMAGE_FORMAT_LEGACY: diff --git a/common/cmd_bootm.c b/common/cmd_bootm.c index ae9c21b..44f6b9f 100644 --- a/common/cmd_bootm.c +++ b/common/cmd_bootm.c @@ -132,8 +132,8 @@ int do_bootm (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]) struct lmb lmb; memset ((void *)&images, 0, sizeof (images)); - images.verify = getenv_verify(); - images.autostart = getenv_autostart(); + images.verify = getenv_yesno ("verify"); + images.autostart = getenv_yesno ("autostart"); images.lmb = &lmb; lmb_init(&lmb); diff --git a/common/cmd_ximg.c b/common/cmd_ximg.c index 7916fc1..2753389 100644 --- a/common/cmd_ximg.c +++ b/common/cmd_ximg.c @@ -51,7 +51,7 @@ do_imgextract(cmd_tbl_t * cmdtp, int flag, int argc, char *argv[]) size_t fit_len; #endif - verify = getenv_verify (); + verify = getenv_yesno ("verify"); if (argc > 1) { addr = simple_strtoul(argv[1], NULL, 16); diff --git a/common/image.c b/common/image.c index 8e72db1..83e3593 100644 --- a/common/image.c +++ b/common/image.c @@ -316,19 +316,27 @@ static void image_print_type (image_header_t *hdr) } /** - * __image_print_contents - prints out the contents of the legacy format image + * image_print_contents - prints out the contents of the legacy format image * @hdr: pointer to the legacy format image header * @p: pointer to prefix string * - * __image_print_contents() formats a multi line legacy image contents description. + * image_print_contents() formats a multi line legacy image contents description. * The routine prints out all header fields followed by the size/offset data * for MULTI/SCRIPT images. * * returns: * no returned results */ -static void __image_print_contents (image_header_t *hdr, const char *p) +void image_print_contents (image_header_t *hdr) { + const char *p; + +#ifdef USE_HOSTCC + p = ""; +#else + p = " "; +#endif + printf ("%sImage Name: %.*s\n", p, IH_NMLEN, image_get_name (hdr)); #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) printf ("%sCreated: ", p); @@ -366,15 +374,6 @@ static void __image_print_contents (image_header_t *hdr, const char *p) } } -inline void image_print_contents (image_header_t *hdr) -{ - __image_print_contents (hdr, " "); -} - -inline void image_print_contents_noindent (image_header_t *hdr) -{ - __image_print_contents (hdr, ""); -} #ifndef USE_HOSTCC /** @@ -444,15 +443,9 @@ static image_header_t* image_get_ramdisk (ulong rd_addr, uint8_t arch, /* Shared dual-format routines */ /*****************************************************************************/ #ifndef USE_HOSTCC -int getenv_verify (void) -{ - char *s = getenv ("verify"); - return (s && (*s == 'n')) ? 0 : 1; -} - -int getenv_autostart (void) +int getenv_yesno (char *var) { - char *s = getenv ("autostart"); + char *s = getenv (var); return (s && (*s == 'n')) ? 0 : 1; } @@ -1265,18 +1258,18 @@ static void fit_get_debug (const void *fit, int noffset, } /** - * __fit_print_contents - prints out the contents of the FIT format image + * fit_print_contents - prints out the contents of the FIT format image * @fit: pointer to the FIT format image header * @p: pointer to prefix string * - * __fit_print_contents() formats a multi line FIT image contents description. + * fit_print_contents() formats a multi line FIT image contents description. * The routine prints out FIT image properties (root node level) follwed by * the details of each component image. * * returns: * no returned results */ -static void __fit_print_contents (const void *fit, const char *p) +void fit_print_contents (const void *fit) { char *desc; char *uname; @@ -1286,10 +1279,17 @@ static void __fit_print_contents (const void *fit, const char *p) int ndepth; int count = 0; int ret; + const char *p; #if defined(CONFIG_TIMESTAMP) || defined(CONFIG_CMD_DATE) || defined(USE_HOSTCC) time_t timestamp; #endif +#ifdef USE_HOSTCC + p = ""; +#else + p = " "; +#endif + /* Root node properties */ ret = fit_get_desc (fit, 0, &desc); printf ("%sFIT description: ", p); @@ -1361,16 +1361,6 @@ static void __fit_print_contents (const void *fit, const char *p) } } -inline void fit_print_contents (const void *fit) -{ - __fit_print_contents (fit, " "); -} - -inline void fit_print_contents_noindent (const void *fit) -{ - __fit_print_contents (fit, ""); -} - /** * fit_image_print - prints out the FIT component image details * @fit: pointer to the FIT format image header |