]> git.kernelconcepts.de Git - karo-tx-uboot.git/commitdiff
Memory footprint optimizations
authorBartlomiej Sieka <tur@semihalf.com>
Fri, 18 Apr 2008 10:39:23 +0000 (12:39 +0200)
committerWolfgang Denk <wd@denx.de>
Thu, 24 Apr 2008 15:21:55 +0000 (17:21 +0200)
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>
board/siemens/common/fpga.c
common/cmd_autoscript.c
common/cmd_bootm.c
common/cmd_ximg.c
common/image.c
include/image.h
tools/mkimage.c

index 48c185082f8d3c5fbbcfd76d69a1e8d4f8d77313..ac0022e7b130980261e1c288e020d75cf2df92fb 100644 (file)
@@ -160,7 +160,7 @@ static int fpga_load (fpga_t* fpga, ulong addr, int checkall)
     data = (uchar*)image_get_data (hdr);
     len  = image_get_data_size (hdr);
 
-    verify = getenv_verify ();
+    verify = getenv_yesno ("verify");
     if (verify) {
        if (!image_check_dcrc (hdr)) {
            strcpy (msg, "Bad Image Data CRC");
index 1a37b90d792f08e6384faff7025df342b4c3533a..932f6388ff699a744d379406dce6555ee49a13f7 100644 (file)
@@ -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:
index ae9c21bda7fb9b20ec450c5aaa20222aa01f46ff..44f6b9f6ea89244feeb557d89748a08c35faed05 100644 (file)
@@ -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);
index 7916fc1972dcee52de85a29720afcbbf2daa63a5..2753389eaee4c93c5bbc998cdc457673ccdc3baa 100644 (file)
@@ -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);
index 8e72db1ef1c1a68c20e798ac796eef04eac0808c..83e359312cda225972da790ac3438b2f56b9ebf8 100644 (file)
@@ -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
index 60fdb2bea36a930122b7cb690cc42a9fbfb5b16d..4076484a5df303637075c0e51cca540c2808e555 100644 (file)
@@ -364,8 +364,7 @@ int image_check_hcrc (image_header_t *hdr);
 int image_check_dcrc (image_header_t *hdr);
 #ifndef USE_HOSTCC
 int image_check_dcrc_wd (image_header_t *hdr, ulong chunksize);
-int getenv_verify (void);
-int getenv_autostart (void);
+int getenv_yesno (char *var);
 ulong getenv_bootm_low(void);
 ulong getenv_bootm_size(void);
 void memmove_wd (void *to, void *from, size_t len, ulong chunksz);
@@ -392,8 +391,7 @@ ulong image_multi_count (image_header_t *hdr);
 void image_multi_getimg (image_header_t *hdr, ulong idx,
                        ulong *data, ulong *len);
 
-inline void image_print_contents (image_header_t *hdr);
-inline void image_print_contents_noindent (image_header_t *hdr);
+void image_print_contents (image_header_t *hdr);
 
 #ifndef USE_HOSTCC
 static inline int image_check_target_arch (image_header_t *hdr)
@@ -469,8 +467,7 @@ inline int fit_parse_conf (const char *spec, ulong addr_curr,
 inline int fit_parse_subimage (const char *spec, ulong addr_curr,
                ulong *addr, const char **image_name);
 
-inline void fit_print_contents (const void *fit);
-inline void fit_print_contents_noindent (const void *fit);
+void fit_print_contents (const void *fit);
 void fit_image_print (const void *fit, int noffset, const char *p);
 void fit_image_print_hash (const void *fit, int noffset, const char *p);
 
index 6e1ff2b1e2f12ca0c0da28c272bc56a0b16f78f9..ea7a826f8c2292d666fba8b53643b0fc29ce095a 100644 (file)
@@ -229,10 +229,10 @@ NXTARG:           ;
                if (fdt_check_header (ptr)) {
                        /* old-style image */
                        image_verify_header ((char *)ptr, sbuf.st_size);
-                       image_print_contents_noindent ((image_header_t *)ptr);
+                       image_print_contents ((image_header_t *)ptr);
                } else {
                        /* FIT image */
-                       fit_print_contents_noindent (ptr);
+                       fit_print_contents (ptr);
                }
 
                (void) munmap((void *)ptr, sbuf.st_size);
@@ -363,7 +363,7 @@ NXTARG:             ;
 
        image_set_hcrc (hdr, checksum);
 
-       image_print_contents_noindent (hdr);
+       image_print_contents (hdr);
 
        (void) munmap((void *)ptr, sbuf.st_size);