summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2016-02-18 23:11:52 +0000
committerhailfinger <hailfinger@2b7e53f0-3cfb-0310-b3e9-8179ed1497e1>2016-02-18 23:11:52 +0000
commit708e90a9bbac693531f6077751b33c39f30912bf (patch)
treeaaa7d008b3485b80c3c58197259d1bf573d92547
parent743844cdafc90b1eb3be44f426592624790bdfcc (diff)
downloadflashrom-708e90a9bbac693531f6077751b33c39f30912bf.tar.gz
Fix chip size limiting in atapromise
The current code is checking model_id to remember if a chip has already been limited, but if flashchips.c contains two subsequent chips with different vendor_id but identical model_id the adjustment will not be done. Switch to checking the chip size instead. If a chip has multiple whole-chip erase functions, only one will be modified. Fix that. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Tested-by: Joseph C. Lehner <joseph.c.lehner@gmail.com> Acked-by: Urja Rannikko <urjaman@gmail.com> git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1930 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1
-rw-r--r--atapromise.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/atapromise.c b/atapromise.c
index d44ff0d..e0de290 100644
--- a/atapromise.c
+++ b/atapromise.c
@@ -79,38 +79,35 @@ void *atapromise_map(const char *descr, uintptr_t phys_addr, size_t len)
static void atapromise_limit_chip(struct flashchip *chip)
{
- static uint32_t last_model_id = 0;
unsigned int i, size;
-
- if (chip->model_id == last_model_id)
- return;
+ unsigned int usable_erasers = 0;
size = chip->total_size * 1024;
- if (size > rom_size) {
- /* Undefine all block_erasers that don't operate on the whole chip,
- * and adjust the eraseblock size of the one that does.
- */
- for (i = 0; i < NUM_ERASEFUNCTIONS; ++i) {
- if (chip->block_erasers[i].eraseblocks[0].size != size) {
- chip->block_erasers[i].eraseblocks[0].count = 0;
- chip->block_erasers[i].block_erase = NULL;
- } else {
- chip->block_erasers[i].eraseblocks[0].size = rom_size;
- break;
- }
- }
- if (i != NUM_ERASEFUNCTIONS) {
- chip->total_size = rom_size / 1024;
- if (chip->page_size > rom_size)
- chip->page_size = rom_size;
+ /* Chip is small enough or already limited. */
+ if (size <= rom_size)
+ return;
+
+ /* Undefine all block_erasers that don't operate on the whole chip,
+ * and adjust the eraseblock size of those which do.
+ */
+ for (i = 0; i < NUM_ERASEFUNCTIONS; ++i) {
+ if (chip->block_erasers[i].eraseblocks[0].size != size) {
+ chip->block_erasers[i].eraseblocks[0].count = 0;
+ chip->block_erasers[i].block_erase = NULL;
} else {
- msg_pdbg("Failed to adjust size of chip \"%s\" (%d kB).\n", chip->name,
- chip->total_size);
+ chip->block_erasers[i].eraseblocks[0].size = rom_size;
+ usable_erasers++;
}
}
- last_model_id = chip->model_id;
+ if (usable_erasers) {
+ chip->total_size = rom_size / 1024;
+ if (chip->page_size > rom_size)
+ chip->page_size = rom_size;
+ } else {
+ msg_pdbg("Failed to adjust size of chip \"%s\" (%d kB).\n", chip->name, chip->total_size);
+ }
}
int atapromise_init(void)