tree/: Make probe_opcode() flashctx argument const
Probing an opcode generally shouldn't involve mutating the flashctx
state and currently no probe_opcode functions do that.
Make the flashctx arg const so that call sites don't need to have a
non-const pointer.
Tested: ninja test
Change-Id: I19e98be50d682de2d2715417f8b7b8c62b871617
Signed-off-by: Nikolai Artemiev <nartemiev@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/70030
Original-Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Original-Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72543
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/dummyflasher.c b/dummyflasher.c
index ba40c6e..9ac83b6 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -112,7 +112,7 @@
static uint16_t dummy_chip_readw(const struct flashctx *flash, const chipaddr addr);
static uint32_t dummy_chip_readl(const struct flashctx *flash, const chipaddr addr);
static void dummy_chip_readn(const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
-static bool dummy_spi_probe_opcode(struct flashctx *flash, uint8_t opcode);
+static bool dummy_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode);
static const struct spi_master spi_master_dummyflasher = {
.features = SPI_MASTER_4BA,
@@ -1187,10 +1187,10 @@
return spi_write_chunked(flash, buf, start, len, data->spi_write_256_chunksize);
}
-static bool dummy_spi_probe_opcode(struct flashctx *flash, uint8_t opcode)
+static bool dummy_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode)
{
size_t i;
- struct emu_data *emu_data = flash->mst->spi.data;
+ const struct emu_data *emu_data = flash->mst->spi.data;
for (i = 0; i < emu_data->spi_blacklist_size; i++) {
if (emu_data->spi_blacklist[i] == opcode)
return false;
diff --git a/ichspi.c b/ichspi.c
index ee29288..afedaf2 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1572,7 +1572,7 @@
return ret;
}
-static bool ich_spi_probe_opcode(struct flashctx *flash, uint8_t opcode)
+static bool ich_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode)
{
return find_opcode(curopcodes, opcode) >= 0;
}
diff --git a/include/programmer.h b/include/programmer.h
index b2c47a5..2a4a8f4 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -307,7 +307,7 @@
int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
int (*shutdown)(void *data);
- bool (*probe_opcode)(struct flashctx *flash, uint8_t opcode);
+ bool (*probe_opcode)(const struct flashctx *flash, uint8_t opcode);
void *data;
};
@@ -317,7 +317,7 @@
int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
int default_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
-bool default_spi_probe_opcode(struct flashctx *flash, uint8_t opcode);
+bool default_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode);
int register_spi_master(const struct spi_master *mst, void *data);
/* The following enum is needed by ich_descriptor_tool and ich* code as well as in chipset_enable.c. */
diff --git a/spi.c b/spi.c
index 98b6b12..bb6f976 100644
--- a/spi.c
+++ b/spi.c
@@ -131,7 +131,7 @@
return default_spi_write_aai(flash, buf, start, len);
}
-bool default_spi_probe_opcode(struct flashctx *flash, uint8_t opcode)
+bool default_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode)
{
return true;
}