[U-Boot] ARM Versatile port - possibly inefficient code?

Hello
Investigating the code for ARM Versatile port, I've found this weird piece of code. If you look in $(UBOOT)/board/versatile/flash.c, line 100, flash_init() :
unsigned long flash_init (void) { int i; ulong size = 0; for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) { switch (i) { case 0: flash_vpp(1); flash_get_size ((FPW *) PHYS_FLASH_1, &flash_info[i]); flash_get_offsets (PHYS_FLASH_1, &flash_info[i]); flash_vpp(0); break; default: panic ("configured too many flash banks!\n"); break; } size += flash_info[i].size; } .....
}
Regardless of CFG_MAX_FLASH_BANKS value, the only first bank is configured. Was it done deliberately or it's logical flaw? I think this code could cloned on a multiple of other platforms.

Hi,
Regardless of CFG_MAX_FLASH_BANKS value, the only first bank is configured. Was it done deliberately or it's logical flaw? I think is code could cloned on a multiple of other platforms.
ARM Versatile has only one flash bank. What if a user has configured an incorrect number for flash banks. The driver should take care of this properly. Since CFG_MAX_FLASH_BANKS is in a different place & the flash.c is a different file, care is taken to see that an incorrect bank is not considered for initialization
also,
panic ("configured too many flash banks!\n");
this error message clearly explains the mistake the user did.
Regards Gururaja

Hello
2008/9/30 Hebbar gururajakr@sanyo.co.in:
ARM Versatile has only one flash bank. What if a user has configured an incorrect number for flash banks.
Hm, I didn't think of it.
The driver should take care of this properly. Since CFG_MAX_FLASH_BANKS is in a different place & the flash.c is a different file, care is taken to see that an incorrect bank is not considered for initialization
Yes, that makes sense then. Thank you.
participants (2)
-
Hebbar
-
Roman Mashak