Fix CFG_NO_FLASH compilation.
Many Atmel boards have no "real" (NOR) flash on board, and rely only
on DataFlash and NAND memories. This patch enables CFG_NO_FLASH to
be present in a board configuration file, while still enabling flash
commands like 'flinfo', 'protect', etc.
Signed-off-by: Stelian Pop <stelian@popies.net>
diff --git a/common/cmd_flash.c b/common/cmd_flash.c
index f56443e..db5dec9 100644
--- a/common/cmd_flash.c
+++ b/common/cmd_flash.c
@@ -41,6 +41,7 @@
u8 *part_num, struct part_info **part);
#endif
+#ifndef CFG_NO_FLASH
extern flash_info_t flash_info[]; /* info for FLASH chips */
/*
@@ -275,15 +276,19 @@
return rcode;
}
+#endif /* CFG_NO_FLASH */
int do_flinfo ( cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
+#ifndef CFG_NO_FLASH
ulong bank;
+#endif
#ifdef CONFIG_HAS_DATAFLASH
dataflash_print_info();
#endif
+#ifndef CFG_NO_FLASH
if (argc == 1) { /* print info for all FLASH banks */
for (bank=0; bank <CFG_MAX_FLASH_BANKS; ++bank) {
printf ("\nBank # %ld: ", bank+1);
@@ -301,11 +306,13 @@
}
printf ("\nBank # %ld: ", bank);
flash_print_info (&flash_info[bank-1]);
+#endif /* CFG_NO_FLASH */
return 0;
}
int do_flerase (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
+#ifndef CFG_NO_FLASH
flash_info_t *info;
ulong bank, addr_first, addr_last;
int n, sect_first, sect_last;
@@ -397,8 +404,12 @@
rcode = flash_sect_erase(addr_first, addr_last);
return rcode;
+#else
+ return 0;
+#endif /* CFG_NO_FLASH */
}
+#ifndef CFG_NO_FLASH
int flash_sect_erase (ulong addr_first, ulong addr_last)
{
flash_info_t *info;
@@ -439,12 +450,17 @@
}
return rcode;
}
+#endif /* CFG_NO_FLASH */
int do_protect (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
+#ifndef CFG_NO_FLASH
flash_info_t *info;
- ulong bank, addr_first, addr_last;
- int i, p, n, sect_first, sect_last;
+ ulong bank;
+ int i, n, sect_first, sect_last;
+#endif /* CFG_NO_FLASH */
+ ulong addr_first, addr_last;
+ int p;
#if defined(CONFIG_CMD_JFFS2) && defined(CONFIG_JFFS2_CMDLINE)
struct mtd_device *dev;
struct part_info *part;
@@ -487,6 +503,7 @@
}
#endif
+#ifndef CFG_NO_FLASH
if (strcmp(argv[2], "all") == 0) {
for (bank=1; bank<=CFG_MAX_FLASH_BANKS; ++bank) {
info = &flash_info[bank-1];
@@ -611,10 +628,11 @@
return 1;
}
rcode = flash_sect_protect (p, addr_first, addr_last);
+#endif /* CFG_NO_FLASH */
return rcode;
}
-
+#ifndef CFG_NO_FLASH
int flash_sect_protect (int p, ulong addr_first, ulong addr_last)
{
flash_info_t *info;
@@ -667,6 +685,7 @@
}
return rcode;
}
+#endif /* CFG_NO_FLASH */
/**************************************************/
diff --git a/common/cmd_mem.c b/common/cmd_mem.c
index 4262e26..d6d7a5b 100644
--- a/common/cmd_mem.c
+++ b/common/cmd_mem.c
@@ -492,7 +492,11 @@
}
/* Check if we are copying from DataFlash to RAM */
- if (addr_dataflash(addr) && !addr_dataflash(dest) && (addr2info(dest)==NULL) ){
+ if (addr_dataflash(addr) && !addr_dataflash(dest)
+#ifndef CFG_NO_FLASH
+ && (addr2info(dest) == NULL)
+#endif
+ ){
int rc;
rc = read_dataflash(addr, count * size, (char *) dest);
if (rc != 1) {