* [U-Boot-Users] [PATCH] CFI: Small cleanup for FLASH_SHOW_PROGRESS
@ 2008-03-19 6:13 Stefan Roese
2008-03-19 12:25 ` Jerry Van Baren
0 siblings, 1 reply; 2+ messages in thread
From: Stefan Roese @ 2008-03-19 6:13 UTC (permalink / raw)
To: u-boot
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>
---
Jerry, what do you think? If you are ok with to this one, and
nobody else has some objections, I'll submit both patches.
drivers/mtd/cfi_flash.c | 22 +++++++++-------------
1 files changed, 9 insertions(+), 13 deletions(-)
diff --git a/drivers/mtd/cfi_flash.c b/drivers/mtd/cfi_flash.c
index 48286e5..f04c72d 100644
--- a/drivers/mtd/cfi_flash.c
+++ b/drivers/mtd/cfi_flash.c
@@ -1185,7 +1185,9 @@ void flash_print_info (flash_info_t * info)
* 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); \
@@ -1194,6 +1196,9 @@ void flash_print_info (flash_info_t * info)
digit--; \
dots += scale; \
}
+#else
+#define FLASH_SHOW_PROGRESS(scale, dots, digit, dots_sub)
+#endif
/*-----------------------------------------------------------------------
* Copy memory to flash, returns:
@@ -1248,10 +1253,7 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
return rc;
wp += i;
-#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 */
@@ -1281,10 +1283,7 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
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) {
@@ -1296,10 +1295,7 @@ int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt)
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 */
--
1.5.4.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [U-Boot-Users] [PATCH] CFI: Small cleanup for FLASH_SHOW_PROGRESS
2008-03-19 6:13 [U-Boot-Users] [PATCH] CFI: Small cleanup for FLASH_SHOW_PROGRESS Stefan Roese
@ 2008-03-19 12:25 ` Jerry Van Baren
0 siblings, 0 replies; 2+ messages in thread
From: Jerry Van Baren @ 2008-03-19 12:25 UTC (permalink / raw)
To: u-boot
Stefan Roese wrote:
> 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>
> ---
>
> Jerry, what do you think? If you are ok with to this one, and
> nobody else has some objections, I'll submit both patches.
>
> drivers/mtd/cfi_flash.c | 22 +++++++++-------------
> 1 files changed, 9 insertions(+), 13 deletions(-)
Yes, there was that little birdie in the back of my mind saying this
could be cleaner when I moved the code into the macro and didn't move
the increment in too (because the increment was different amounts).
Thanks for chirping louder. :-)
Acked-by: Gerald Van Baren <vanbaren@cideas.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2008-03-19 12:25 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-19 6:13 [U-Boot-Users] [PATCH] CFI: Small cleanup for FLASH_SHOW_PROGRESS Stefan Roese
2008-03-19 12:25 ` Jerry Van Baren
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox