1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 14:11:15 +02:00

tree/: Convert flashchip erase_block func ptr to enumerate

This forges the way for flashchips.c to be pure declarative
data and lookup functions for dispatch to be pure. This
means that the flashchips data could be extracted out to
be agnostic data of the flashrom code and algorithms.

Change-Id: I02ae7e4c67c5bf34ec2fd7ffe4af8a2aba6fd5e5
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/69133
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Edward O'Callaghan
2022-08-29 10:36:21 +10:00
committed by Edward O'Callaghan
parent 3c44e12a28
commit 3bba710d98
7 changed files with 108 additions and 47 deletions

View File

@ -619,7 +619,7 @@ int spi_block_erase_dc(struct flashctx *flash, unsigned int addr, unsigned int b
}
static const struct {
erasefunc_t *func;
enum block_erase_func func;
uint8_t opcode;
} function_opcode_list[] = {
{SPI_BLOCK_ERASE_20, 0x20},
@ -639,7 +639,7 @@ static const struct {
{SPI_BLOCK_ERASE_DC, 0xdc},
};
erasefunc_t *spi_get_erasefn_from_opcode(uint8_t opcode)
enum block_erase_func spi_get_erasefn_from_opcode(uint8_t opcode)
{
size_t i;
for (i = 0; i < ARRAY_SIZE(function_opcode_list); i++) {
@ -651,14 +651,14 @@ erasefunc_t *spi_get_erasefn_from_opcode(uint8_t opcode)
return NO_BLOCK_ERASE_FUNC;
}
uint8_t spi_get_opcode_from_erasefn(erasefunc_t *func)
uint8_t spi_get_opcode_from_erasefn(enum block_erase_func func)
{
size_t i;
for (i = 0; i < ARRAY_SIZE(function_opcode_list); i++) {
if (function_opcode_list[i].func == func)
return function_opcode_list[i].opcode;
}
msg_cinfo("%s: unknown erase function (0x%p). Please report "
msg_cinfo("%s: unknown erase function (0x%d). Please report "
"this at flashrom@flashrom.org\n", __func__, func);
return 0x00; //Assuming 0x00 is not a erase function opcode
}