[U-Boot-Users] [PATCH] use CFI-Flash and board depended driver together
Timur Tabi
timur at freescale.com
Thu Nov 30 15:22:59 CET 2006
Jens Scharsig wrote:
> +#ifdef CFG_FLASH_BOARD_DRIVER
> +#define flash_print_info cfi_flash_print_info
> +#define flash_erase cfi_flash_erase
> +#define write_buff cfi_write_buff
> +#define flash_real_protect cfi_flash_real_protect
> +#endif
Ugh, I really dislike code like this. I know Wolfgang has the final say
on these things, but I would rather you did something else. For
instance, if CFG_FLASH_BOARD_DRIVER is not defined, then the cfi_xxx
functions are defined here. Otherwise, they are declared as externs and
they need to be defined in the board file. Like this:
#ifdef CFG_FLASH_BOARD_DRIVER
extern ... cfi_flash_print_info(...);
extern ... cfi_flash_erase(...);
extern ... cfi_write_buff(...);
extern ... cfi_flash_real_protect(...);
#else
... cfi_flash_print_info(...)
{
// original cfi_flash_print_info code here
}
// and so on
#endif
> +#ifdef CFG_FLASH_BOARD_DRIVER
> + size += flash_info[i].size = board_flash_get_size (bank_base[i], i);
> +#else
> size += flash_info[i].size = flash_get_size (bank_base[i], i);
> +#endif
You could do the same thing here. Rename flash_get_size() to
cfi_flash_get_size() and treat it like the other cfi_xxx functions above.
More information about the U-Boot
mailing list