With this patch we don't need that many #ifdef's in the code. It moves
the subtraction into the macro and defines a NOP-macro when
CONFIG_FLASH_SHOW_PROGRESS is not defined.
Signed-off-by: Stefan Roese <sr@denx.de>
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
* effect updates to digit and dots. Repeated code is nasty too, so
* we define it once here.
*/
* effect updates to digit and dots. Repeated code is nasty too, so
* we define it once here.
*/
-#define FLASH_SHOW_PROGRESS(scale, dots, digit) \
+#ifdef CONFIG_FLASH_SHOW_PROGRESS
+#define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub) \
+ dots -= dots_sub; \
if ((scale > 0) && (dots <= 0)) { \
if ((digit % 5) == 0) \
printf ("%d", digit / 5); \
if ((scale > 0) && (dots <= 0)) { \
if ((digit % 5) == 0) \
printf ("%d", digit / 5); \
digit--; \
dots += scale; \
}
digit--; \
dots += scale; \
}
+#else
+#define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub)
+#endif
/*-----------------------------------------------------------------------
* Copy memory to flash, returns:
/*-----------------------------------------------------------------------
* Copy memory to flash, returns:
-#ifdef CONFIG_FLASH_SHOW_PROGRESS
- dots -= i;
- FLASH_SHOW_PROGRESS(scale, dots, digit);
-#endif
+ FLASH_SHOW_PROGRESS(scale, dots, digit, i);
}
/* handle the aligned part */
}
/* handle the aligned part */
wp += i;
src += i;
cnt -= i;
wp += i;
src += i;
cnt -= i;
-#ifdef CONFIG_FLASH_SHOW_PROGRESS
- dots -= i;
- FLASH_SHOW_PROGRESS(scale, dots, digit);
-#endif
+ FLASH_SHOW_PROGRESS(scale, dots, digit, i);
}
#else
while (cnt >= info->portwidth) {
}
#else
while (cnt >= info->portwidth) {
return rc;
wp += info->portwidth;
cnt -= info->portwidth;
return rc;
wp += info->portwidth;
cnt -= info->portwidth;
-#ifdef CONFIG_FLASH_SHOW_PROGRESS
- dots -= info->portwidth;
- FLASH_SHOW_PROGRESS(scale, dots, digit);
-#endif
+ FLASH_SHOW_PROGRESS(scale, dots, digit, info->portwidth);
}
#endif /* CFG_FLASH_USE_BUFFER_WRITE */
}
#endif /* CFG_FLASH_USE_BUFFER_WRITE */