diff options
author | Edward O'Callaghan <quasisec@google.com> | 2022-11-23 22:36:53 +1100 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2023-03-20 00:36:56 +0000 |
commit | 0c774d6b6a075f37f21ca9c3506141cb0d4ae34b (patch) | |
tree | 695a252de5954213b1ceeffecef302394f26c2e6 /tests | |
parent | 028099dbfd92e62eb0c6227d1194ff714f55e67c (diff) | |
download | flashrom-0c774d6b6a075f37f21ca9c3506141cb0d4ae34b.tar.gz flashrom-0c774d6b6a075f37f21ca9c3506141cb0d4ae34b.tar.bz2 flashrom-0c774d6b6a075f37f21ca9c3506141cb0d4ae34b.zip |
tree/: Convert unlock func ptr into enumerate values
Converting the blockprotect unlock function pointer
within the flashchip struct into enum values allows for
the flashchips db to be turn into pure, declarative data.
A nice side-effect of this is to reduce link-time symbol
space of chipdrivers and increase modularity of the
spi25_statusreg.c and related implementations.
BUG=none
TEST=ninja test.
Change-Id: Ie5c5db1b09d07e1a549990d6f5a622fae4c83233
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/69933
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/chip.c | 9 | ||||
-rw-r--r-- | tests/chip_wp.c | 2 |
2 files changed, 8 insertions, 3 deletions
diff --git a/tests/chip.c b/tests/chip.c index ad0d7701..6a17d862 100644 --- a/tests/chip.c +++ b/tests/chip.c @@ -149,6 +149,7 @@ static void teardown(struct flashrom_layout **layout) extern write_func_t *g_test_write_injector; extern read_func_t *g_test_read_injector; extern erasefunc_t *g_test_erase_injector; +extern blockprotect_func_t *g_test_unlock_injector; static const struct flashchip chip_8MiB = { .vendor = "aklm", @@ -156,7 +157,7 @@ static const struct flashchip chip_8MiB = { .tested = TEST_OK_PREW, .read = TEST_READ_INJECTOR, .write = TEST_WRITE_INJECTOR, - .unlock = unlock_chip, + .unlock = TEST_UNLOCK_INJECTOR, .block_erasers = {{ /* All blocks within total size of the chip. */ @@ -172,7 +173,7 @@ static const struct flashchip chip_W25Q128_V = { .tested = TEST_OK_PREW, .read = SPI_CHIP_READ, .write = SPI_CHIP_WRITE256, - .unlock = spi_disable_blockprotect, + .unlock = SPI_DISABLE_BLOCKPROTECT, .page_size = 256, .block_erasers = { @@ -210,6 +211,7 @@ void erase_chip_test_success(void **state) g_test_write_injector = write_chip; g_test_read_injector = read_chip; g_test_erase_injector = block_erase_chip; + g_test_unlock_injector = unlock_chip; struct flashrom_flashctx flashctx = { 0 }; struct flashrom_layout *layout; struct flashchip mock_chip = chip_8MiB; @@ -269,6 +271,7 @@ void read_chip_test_success(void **state) g_test_write_injector = write_chip; g_test_read_injector = read_chip; g_test_erase_injector = block_erase_chip; + g_test_unlock_injector = unlock_chip; struct flashrom_flashctx flashctx = { 0 }; struct flashrom_layout *layout; struct flashchip mock_chip = chip_8MiB; @@ -344,6 +347,7 @@ void write_chip_test_success(void **state) g_test_write_injector = write_chip; g_test_read_injector = read_chip; g_test_erase_injector = block_erase_chip; + g_test_unlock_injector = unlock_chip; struct flashrom_flashctx flashctx = { 0 }; struct flashrom_layout *layout; struct flashchip mock_chip = chip_8MiB; @@ -535,6 +539,7 @@ void verify_chip_test_success(void **state) g_test_write_injector = write_chip; g_test_read_injector = read_chip; g_test_erase_injector = block_erase_chip; + g_test_unlock_injector = unlock_chip; struct flashrom_flashctx flashctx = { 0 }; struct flashrom_layout *layout; struct flashchip mock_chip = chip_8MiB; diff --git a/tests/chip_wp.c b/tests/chip_wp.c index 9607a96e..2686f446 100644 --- a/tests/chip_wp.c +++ b/tests/chip_wp.c @@ -67,7 +67,7 @@ static const struct flashchip chip_W25Q128_V = { .tested = TEST_OK_PREW, .read = SPI_CHIP_READ, .write = SPI_CHIP_WRITE256, - .unlock = spi_disable_blockprotect, + .unlock = SPI_DISABLE_BLOCKPROTECT, .feature_bits = FEATURE_WRSR_WREN | FEATURE_OTP | FEATURE_WRSR_EXT2 | FEATURE_WRSR2 | FEATURE_WRSR3, .block_erasers = { |