Use the register mapping feature bit
All functions which just call probe_jedec and then map flash registers
are replaced by probe_jedec. All functions which call probe_jedec, map
flash registers and do something else can at least eliminate mapping
flash registers.
Fix logic inversion in probe_jedec to map flash registers on success
instead of on failure.
Change a few TIMING_IGNORED to TIMING_FIXME where probe_jedec is used.
Total savings: One probe function simplified, three probe functions
eliminated.
Corresponding to flashrom svn r839.
Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
Acked-by: Sean Nelson <audiohacked@gmail.com>
diff --git a/flashchips.c b/flashchips.c
index e6c4b86..913e030 100644
--- a/flashchips.c
+++ b/flashchips.c
@@ -827,7 +827,7 @@
.total_size = 64,
.page_size = 128,
.tested = TEST_OK_PRW,
- .probe = probe_jedec,
+ .probe = probe_jedec,
.probe_timing = 10000, /* 10mS, Enter=Exec */
.erase = NULL,
.block_erasers =
@@ -1252,8 +1252,9 @@
.model_id = AMIC_A49LF040A,
.total_size = 512,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
- .probe = probe_49fl00x,
+ .probe = probe_jedec,
.probe_timing = TIMING_ZERO, /* routine is wrapper to probe_jedec (pm49fl00x.c) */
.erase = erase_49fl00x,
.write = write_49fl00x,
@@ -2473,8 +2474,9 @@
.model_id = PMC_49FL002,
.total_size = 256,
.page_size = 16 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
- .probe = probe_49fl00x,
+ .probe = probe_jedec,
.probe_timing = TIMING_ZERO, /* routine is wrapper to probe_jedec (pm49fl00x.c) */
.erase = erase_49fl00x,
.write = write_49fl00x,
@@ -2489,8 +2491,9 @@
.model_id = PMC_49FL004,
.total_size = 512,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
- .probe = probe_49fl00x,
+ .probe = probe_jedec,
.probe_timing = TIMING_ZERO, /* routine is wrapper to probe_jedec (pm49fl00x.c) */
.erase = erase_49fl00x,
.write = write_49fl00x,
@@ -2980,6 +2983,7 @@
.model_id = SST_49LF002A,
.total_size = 256,
.page_size = 16 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
.probe = probe_sst_fwhub,
.probe_timing = 1, /* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
@@ -2996,6 +3000,7 @@
.model_id = SST_49LF003A,
.total_size = 384,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PR,
.probe = probe_sst_fwhub,
.probe_timing = 1, /* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
@@ -3015,6 +3020,7 @@
.model_id = SST_49LF004A,
.total_size = 512,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
.probe = probe_sst_fwhub,
.probe_timing = 1, /* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
@@ -3060,6 +3066,7 @@
.model_id = SST_49LF008A,
.total_size = 1024,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
.probe = probe_sst_fwhub,
.probe_timing = 1, /* 150 ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
@@ -3156,6 +3163,7 @@
.model_id = SST_49LF040B,
.total_size = 512,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
.probe = probe_sst_fwhub,
.probe_timing = 1, /* 150ns | routine is wrapper to probe_jedec (sst_fwhub.c) */
@@ -3498,8 +3506,9 @@
.model_id = ST_M50FLW040A,
.total_size = 512,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_UNTESTED,
- .probe = probe_stm50flw0x0x,
+ .probe = probe_jedec,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (stm50flw0x0x.c) */
.erase = erase_stm50flw0x0x,
.write = write_stm50flw0x0x,
@@ -3514,8 +3523,9 @@
.model_id = ST_M50FLW040B,
.total_size = 512,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_UNTESTED,
- .probe = probe_stm50flw0x0x,
+ .probe = probe_jedec,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (stm50flw0x0x.c) */
.erase = erase_stm50flw0x0x,
.write = write_stm50flw0x0x,
@@ -3530,8 +3540,9 @@
.model_id = ST_M50FLW080A,
.total_size = 1024,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
- .probe = probe_stm50flw0x0x,
+ .probe = probe_jedec,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (stm50flw0x0x.c) */
.erase = erase_stm50flw0x0x,
.write = write_stm50flw0x0x,
@@ -3546,8 +3557,9 @@
.model_id = ST_M50FLW080B,
.total_size = 1024,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_UNTESTED,
- .probe = probe_stm50flw0x0x,
+ .probe = probe_jedec,
.probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (stm50flw0x0x.c) */
.erase = erase_stm50flw0x0x,
.write = write_stm50flw0x0x,
@@ -4042,9 +4054,10 @@
.model_id = W_39V080FA,
.total_size = 1024,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_OK_PREW,
- .probe = probe_winbond_fwhub,
- .probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (w39v080fa.c) */
+ .probe = probe_jedec,
+ .probe_timing = TIMING_FIXME,
.erase = erase_winbond_fwhub,
.write = write_winbond_fwhub,
.read = read_memmapped,
@@ -4058,9 +4071,10 @@
.model_id = W_39V080FA_DM,
.total_size = 512,
.page_size = 64 * 1024,
+ .feature_bits = FEATURE_REGISTERMAP,
.tested = TEST_UNTESTED,
- .probe = probe_winbond_fwhub,
- .probe_timing = TIMING_IGNORED, /* routine don't use probe_timing (w39v080fa.c) */
+ .probe = probe_jedec,
+ .probe_timing = TIMING_FIXME,
.erase = erase_winbond_fwhub,
.write = write_winbond_fwhub,
.read = read_memmapped,
diff --git a/jedec.c b/jedec.c
index e1bd12f..3a21539 100644
--- a/jedec.c
+++ b/jedec.c
@@ -189,13 +189,13 @@
printf_debug(", id2 is normal flash content");
printf_debug("\n");
- if (largeid1 == flash->manufacture_id && largeid2 == flash->model_id)
- return 1;
+ if (largeid1 != flash->manufacture_id || largeid2 != flash->model_id)
+ return 0;
if (flash->feature_bits & FEATURE_REGISTERMAP)
map_flash_registers(flash);
- return 0;
+ return 1;
}
int erase_sector_jedec_common(struct flashchip *flash, unsigned int page,
diff --git a/pm49fl00x.c b/pm49fl00x.c
index 424b0ed..9d104e2 100644
--- a/pm49fl00x.c
+++ b/pm49fl00x.c
@@ -36,16 +36,6 @@
}
}
-int probe_49fl00x(struct flashchip *flash)
-{
- int ret = probe_jedec(flash);
-
- if (ret == 1)
- map_flash_registers(flash);
-
- return ret;
-}
-
int erase_49fl00x(struct flashchip *flash)
{
int i;
diff --git a/sst_fwhub.c b/sst_fwhub.c
index 4a976e6..b29722f 100644
--- a/sst_fwhub.c
+++ b/sst_fwhub.c
@@ -89,8 +89,6 @@
if (probe_jedec(flash) == 0)
return 0;
- map_flash_registers(flash);
-
for (i = 0; i < flash->total_size * 1024; i += flash->page_size)
check_sst_fwhub_block_lock(flash, i);
diff --git a/stm50flw0x0x.c b/stm50flw0x0x.c
index 0ae6eb8..e90bbd2 100644
--- a/stm50flw0x0x.c
+++ b/stm50flw0x0x.c
@@ -31,18 +31,6 @@
#include "flash.h"
#include "flashchips.h"
-int probe_stm50flw0x0x(struct flashchip *flash)
-{
- int result = probe_jedec(flash);
-
- if (!result)
- return result;
-
- map_flash_registers(flash);
-
- return 1;
-}
-
static void wait_stm50flw0x0x(chipaddr bios)
{
chip_writeb(0x70, bios);
diff --git a/w39v080fa.c b/w39v080fa.c
index 311e55b..8e846dc 100644
--- a/w39v080fa.c
+++ b/w39v080fa.c
@@ -20,18 +20,6 @@
#include "flash.h"
-int probe_winbond_fwhub(struct flashchip *flash)
-{
- int result = probe_jedec(flash);
-
- if (!result)
- return result;
-
- map_flash_registers(flash);
-
- return 1;
-}
-
static int unlock_block_winbond_fwhub(struct flashchip *flash, int offset)
{
chipaddr wrprotect = flash->virtual_registers + offset + 2;