Move common, watchdog sensible memmove code to a helper memmmove_wd() routine.
Signed-off-by: Marian Balakowicz <m8@semihalf.com>
                if (image_get_load (hdr) == addr) {
                        printf ("   XIP %s ... ", name);
                } else {
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-                       size_t l = len;
-                       void *to = (void *)image_get_load (hdr);
-                       void *from = (void *)data;
-
                        printf ("   Loading %s ... ", name);
 
-                       while (l > 0) {
-                               size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
-                               WATCHDOG_RESET();
-                               memmove (to, from, tail);
-                               to += tail;
-                               from += tail;
-                               l -= tail;
-                       }
-#else  /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-                       memmove ((void *)image_get_load (hdr), (uchar *)data, len);
-#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+                       memmove_wd ((void *)image_get_load (hdr),
+                                  (void *)data, len, CHUNKSZ);
+
+                       puts("OK\n");
                }
                break;
        case IH_COMP_GZIP:
 
        return (dcrc == image_get_dcrc (hdr));
 }
 
+#ifndef USE_HOSTCC
 int image_check_dcrc_wd (image_header_t *hdr, ulong chunksz)
 {
        ulong dcrc = 0;
        char *s = getenv ("verify");
        return (s && (*s == 'n')) ? 0 : 1;
 }
+
+void memmove_wd (void *to, void *from, size_t len, ulong chunksz)
+{
+#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
+       while (len > 0) {
+               size_t tail = (len > chunksz) ? chunksz : len;
+               WATCHDOG_RESET ();
+               memmove (to, from, tail);
+               to += tail;
+               from += tail;
+               len -= tail;
+       }
+#else  /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
+       memmove (to, from, len);
+#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+}
+#endif /* USE_HOSTCC */
 
 
 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);
+void memmove_wd (void *to, void *from, size_t len, ulong chunksz);
+#endif
 
 static inline int image_check_magic (image_header_t *hdr)
 {
 
                        initrd_end = initrd_start + len;
                        printf("   Loading Ramdisk to %08lx, end %08lx ... ",
                               initrd_start, initrd_end);
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-                       {
-                               size_t l = len;
-                               void *to = (void *)initrd_start;
-                               void *from = (void *)data;
-
-                               while (l > 0) {
-                                       size_t tail =
-                                           (l > CHUNKSZ) ? CHUNKSZ : l;
-                                       WATCHDOG_RESET();
-                                       memmove(to, from, tail);
-                                       to += tail;
-                                       from += tail;
-                                       l -= tail;
-                               }
-                       }
-#else                          /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-                       memmove((void *)initrd_start, (void *)data, len);
-#endif                         /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+
+                       memmove_wd((void *)initrd_start,
+                                  (void *)data, len, CHUNKSZ);
+
                        puts("OK\n");
                }
        } else {
 
                initrd_end    = initrd_start + len;
                printf ("   Loading Ramdisk to %08lx, end %08lx ... ",
                        initrd_start, initrd_end);
-#if defined(CONFIG_HW_WATCHDOG) || defined(CONFIG_WATCHDOG)
-               {
-                       size_t l = len;
-                       void *to = (void *)initrd_start;
-                       void *from = (void *)data;
-
-                       while (l > 0) {
-                               size_t tail = (l > CHUNKSZ) ? CHUNKSZ : l;
-                               WATCHDOG_RESET();
-                               memmove (to, from, tail);
-                               to += tail;
-                               from += tail;
-                               l -= tail;
-                       }
-               }
-#else  /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-               memmove ((void *)initrd_start, (void *)data, len);
-#endif /* CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG */
+
+               memmove_wd((void *)initrd_start,
+                          (void *)data, len, CHUNKSZ);
+
                puts ("OK\n");
            }
        } else {