aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-06-26 17:04:16 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2011-06-26 17:04:16 +0000
commitb4061f61cdf951760020c6d4789023d4001b9782 (patch)
tree99b4aec1edbe35372a0fe653b5448f52c0fe98c8
parentbfa021dd80594e51fa25feee56457d545849e312 (diff)
downloadflashrom-b4061f61cdf951760020c6d4789023d4001b9782.tar.gz
flashrom-b4061f61cdf951760020c6d4789023d4001b9782.tar.bz2
flashrom-b4061f61cdf951760020c6d4789023d4001b9782.zip
Move erase verification to generic code
Erase functions are no longer called from chip drivers and thus their internal erase verification can be moved to generic code. This also makes it easier to skip the verify step if desired and to differentiate between failed command submission and failed erase verification. Corresponding to flashrom svn r1353. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at>
-rw-r--r--82802ab.c6
-rw-r--r--flash.h1
-rw-r--r--flashrom.c4
-rw-r--r--jedec.c16
-rw-r--r--m29f400bt.c10
-rw-r--r--sharplhf00l04.c5
-rw-r--r--spi25.c30
-rw-r--r--sst28sf040.c10
-rw-r--r--sst49lfxxxc.c5
-rw-r--r--stm50flw0x0x.c6
10 files changed, 21 insertions, 72 deletions
diff --git a/82802ab.c b/82802ab.c
index 09b95e6c..25807062 100644
--- a/82802ab.c
+++ b/82802ab.c
@@ -136,11 +136,7 @@ int erase_block_82802ab(struct flashchip *flash, unsigned int page, unsigned int
status = wait_82802ab(flash);
print_status_82802ab(status);
- if (check_erased_range(flash, page, pagesize)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
-
+ /* FIXME: Check the status register for errors. */
return 0;
}
diff --git a/flash.h b/flash.h
index f8751025..16e57088 100644
--- a/flash.h
+++ b/flash.h
@@ -210,7 +210,6 @@ int min(int a, int b);
int max(int a, int b);
void tolower_string(char *str);
char *extract_param(char **haystack, char *needle, char *delim);
-int check_erased_range(struct flashchip *flash, int start, int len);
int verify_range(struct flashchip *flash, uint8_t *cmpbuf, int start, int len, char *message);
int need_erase(uint8_t *have, uint8_t *want, int len, enum write_granularity gran);
char *strcat_realloc(char *dest, const char *src);
diff --git a/flashrom.c b/flashrom.c
index 6979d84c..13dd5819 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1400,6 +1400,10 @@ static int erase_and_write_block_helper(struct flashchip *flash,
ret = erasefn(flash, start, len);
if (ret)
return ret;
+ if (check_erased_range(flash, start, len)) {
+ msg_cerr("ERASE FAILED!\n");
+ return -1;
+ }
/* Erase was successful. Adjust curcontents. */
memset(curcontents, 0xff, len);
skip = 0;
diff --git a/jedec.c b/jedec.c
index f23cf535..b96f5fd9 100644
--- a/jedec.c
+++ b/jedec.c
@@ -264,10 +264,7 @@ static int erase_sector_jedec_common(struct flashchip *flash, unsigned int page,
/* wait for Toggle bit ready */
toggle_ready_jedec_slow(bios);
- if (check_erased_range(flash, page, pagesize)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
@@ -297,16 +294,12 @@ static int erase_block_jedec_common(struct flashchip *flash, unsigned int block,
/* wait for Toggle bit ready */
toggle_ready_jedec_slow(bios);
- if (check_erased_range(flash, block, blocksize)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
static int erase_chip_jedec_common(struct flashchip *flash, unsigned int mask)
{
- int total_size = flash->total_size * 1024;
chipaddr bios = flash->virtual_memory;
int delay_us = 0;
if(flash->probe_timing != TIMING_ZERO)
@@ -329,10 +322,7 @@ static int erase_chip_jedec_common(struct flashchip *flash, unsigned int mask)
toggle_ready_jedec_slow(bios);
- if (check_erased_range(flash, 0, total_size)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
diff --git a/m29f400bt.c b/m29f400bt.c
index 7e4f51c8..e0d41d4e 100644
--- a/m29f400bt.c
+++ b/m29f400bt.c
@@ -101,10 +101,7 @@ int erase_m29f400bt(struct flashchip *flash)
programmer_delay(10);
toggle_ready_jedec(bios);
- if (check_erased_range(flash, 0, flash->total_size * 1024)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
@@ -124,10 +121,7 @@ int block_erase_m29f400bt(struct flashchip *flash, unsigned int start, unsigned
programmer_delay(10);
toggle_ready_jedec(bios);
- if (check_erased_range(flash, start, len)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
diff --git a/sharplhf00l04.c b/sharplhf00l04.c
index f21950aa..4865fc27 100644
--- a/sharplhf00l04.c
+++ b/sharplhf00l04.c
@@ -50,9 +50,6 @@ int erase_lhf00l04_block(struct flashchip *flash, unsigned int blockaddr, unsign
status = wait_82802ab(flash);
print_status_82802ab(status);
- if (check_erased_range(flash, blockaddr, blocklen)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
diff --git a/spi25.c b/spi25.c
index d3680fb0..b26f533b 100644
--- a/spi25.c
+++ b/spi25.c
@@ -481,10 +481,7 @@ int spi_chip_erase_60(struct flashchip *flash)
/* FIXME: We assume spi_read_status_register will never fail. */
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
programmer_delay(1000 * 1000);
- if (check_erased_range(flash, 0, flash->total_size * 1024)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
@@ -520,10 +517,7 @@ int spi_chip_erase_c7(struct flashchip *flash)
/* FIXME: We assume spi_read_status_register will never fail. */
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
programmer_delay(1000 * 1000);
- if (check_erased_range(flash, 0, flash->total_size * 1024)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
@@ -564,10 +558,7 @@ int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int
*/
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
programmer_delay(100 * 1000);
- if (check_erased_range(flash, addr, blocklen)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
@@ -613,10 +604,7 @@ int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int
*/
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
programmer_delay(100 * 1000);
- if (check_erased_range(flash, addr, blocklen)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
@@ -660,10 +648,7 @@ int spi_block_erase_d7(struct flashchip *flash, unsigned int addr, unsigned int
*/
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
programmer_delay(100 * 1000);
- if (check_erased_range(flash, addr, blocklen)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
@@ -705,10 +690,7 @@ int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int
*/
while (spi_read_status_register() & JEDEC_RDSR_BIT_WIP)
programmer_delay(10 * 1000);
- if (check_erased_range(flash, addr, blocklen)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
diff --git a/sst28sf040.c b/sst28sf040.c
index 0fbf098e..d621cc75 100644
--- a/sst28sf040.c
+++ b/sst28sf040.c
@@ -71,10 +71,7 @@ int erase_sector_28sf040(struct flashchip *flash, unsigned int address, unsigned
/* wait for Toggle bit ready */
toggle_ready_jedec(bios);
- if (check_erased_range(flash, address, sector_size)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
@@ -113,10 +110,7 @@ static int erase_28sf040(struct flashchip *flash)
programmer_delay(10);
toggle_ready_jedec(bios);
- if (check_erased_range(flash, 0, flash->total_size * 1024)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
diff --git a/sst49lfxxxc.c b/sst49lfxxxc.c
index 392d7a84..28f6cd09 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -70,9 +70,6 @@ int erase_sector_49lfxxxc(struct flashchip *flash, unsigned int address, unsigne
status = wait_82802ab(flash);
print_status_82802ab(status);
- if (check_erased_range(flash, address, sector_size)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
+ /* FIXME: Check the status register for errors. */
return 0;
}
diff --git a/stm50flw0x0x.c b/stm50flw0x0x.c
index 726a882d..f3fc4d8f 100644
--- a/stm50flw0x0x.c
+++ b/stm50flw0x0x.c
@@ -107,10 +107,6 @@ int erase_sector_stm50flw0x0x(struct flashchip *flash, unsigned int sector, unsi
wait_82802ab(flash);
- if (check_erased_range(flash, sector, sectorsize)) {
- msg_cerr("ERASE FAILED!\n");
- return -1;
- }
-
+ /* FIXME: Check the status register for errors. */
return 0;
}