Edward O'Callaghan has uploaded this change for review.
flashrom: Fix probe_flash()
Change-Id: I99f54ae0e70ec8d089a9113a6d9e96bd79994418
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M cli_classic.c
M flashrom.c
M include/flash.h
M libflashrom.c
4 files changed, 23 insertions(+), 8 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/61/67361/1
diff --git a/cli_classic.c b/cli_classic.c
index bac31d1..bb324f9 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -931,10 +931,13 @@
msg_pdbg("The following protocols are supported: %s.\n", tempstr);
free(tempstr);
+ /* TODO(quasisec): This cast works for the moment while types are isomorphic. */
+ struct flashrom_programmer *flashprog = (struct flashrom_programmer *)prog;
+
for (j = 0; j < registered_master_count; j++) {
startchip = 0;
while (chipcount < (int)ARRAY_SIZE(flashes)) {
- startchip = probe_flash(®istered_masters[j], startchip, &flashes[chipcount], 0);
+ startchip = probe_flash(flashprog, ®istered_masters[j], startchip, &flashes[chipcount], 0);
if (startchip == -1)
break;
chipcount++;
@@ -977,7 +980,7 @@
"chip, using the first one.\n");
for (j = 0; j < registered_master_count; j++) {
mst = ®istered_masters[j];
- startchip = probe_flash(mst, 0, &flashes[0], 1);
+ startchip = probe_flash(flashprog, mst, 0, &flashes[0], 1);
if (startchip != -1)
break;
}
diff --git a/flashrom.c b/flashrom.c
index 4706d89..9cff43a 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -707,11 +707,13 @@
return ret;
}
-int probe_flash(struct registered_master *mst, int startchip, struct flashctx *flash, int force)
+int probe_flash(const struct flashrom_programmer *const flashprog, struct registered_master *mst,
+ int startchip, struct flashctx *flash, int force)
{
const struct flashchip *chip;
enum chipbustype buses_common;
char *tmp;
+ const struct programmer_entry *prog = (struct programmer_entry *)flashprog;
for (chip = flashchips + startchip; chip && chip->name; chip++) {
if (chip_to_probe && strcmp(chip->name, chip_to_probe) != 0)
@@ -807,12 +809,12 @@
flash->chip->vendor, flash->chip->name, flash->chip->total_size, tmp);
free(tmp);
#if CONFIG_INTERNAL == 1
- if (programmer->map_flash_region == physmap)
+ if (prog->map_flash_region == physmap)
msg_cinfo("mapped at physical address 0x%0*" PRIxPTR ".\n",
PRIxPTR_WIDTH, flash->physical_memory);
else
#endif
- msg_cinfo("on %s.\n", programmer->name);
+ msg_cinfo("on %s.\n", prog->name);
/* Flash registers may more likely not be mapped if the chip was forced.
* Lock info may be stored in registers, so avoid lock info printing. */
diff --git a/include/flash.h b/include/flash.h
index 79aaa64..ba1fb17 100644
--- a/include/flash.h
+++ b/include/flash.h
@@ -415,7 +415,7 @@
void unmap_flash(struct flashctx *flash);
int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int erase_flash(struct flashctx *flash);
-int probe_flash(struct registered_master *mst, int startchip, struct flashctx *fill_flash, int force);
+int probe_flash(const struct flashrom_programmer *const flashprog, struct registered_master *mst, int startchip, struct flashctx *fill_flash, int force);
int verify_range(struct flashctx *flash, const uint8_t *cmpbuf, unsigned int start, unsigned int len);
void emergency_help_message(void);
void print_version(void);
diff --git a/libflashrom.c b/libflashrom.c
index 2febf30..50da72e 100644
--- a/libflashrom.c
+++ b/libflashrom.c
@@ -244,10 +244,10 @@
for (i = 0; i < registered_master_count; ++i) {
int flash_idx = -1;
- if (!ret || (flash_idx = probe_flash(®istered_masters[i], 0, *flashctx, 0)) != -1) {
+ if (!ret || (flash_idx = probe_flash(flashprog, ®istered_masters[i], 0, *flashctx, 0)) != -1) {
ret = 0;
/* We found one chip, now check that there is no second match. */
- if (probe_flash(®istered_masters[i], flash_idx + 1, &second_flashctx, 0) != -1) {
+ if (probe_flash(flashprog, ®istered_masters[i], flash_idx + 1, &second_flashctx, 0) != -1) {
flashrom_layout_release(second_flashctx.default_layout);
free(second_flashctx.chip);
ret = 3;
To view, visit change 67361. To unsubscribe, or for help writing mail filters, visit settings.