From mboxrd@z Thu Jan 1 00:00:00 1970 From: Timur Tabi Date: Thu, 30 Nov 2006 08:22:59 -0600 Subject: [U-Boot-Users] [PATCH] use CFI-Flash and board depended driver together In-Reply-To: References: Message-ID: <456EE943.3010003@freescale.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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.