From 2e00f736714c3117354106c502a8c89b23896b2b Mon Sep 17 00:00:00 2001 From: Nikolai Artemiev Date: Tue, 30 Aug 2022 11:11:13 +1000 Subject: tree/: Convert flashchip decode range func ptr to enum Replace the `decode_range` function pointer in `struct flashchip` to an enum value. The enum value can be used to find the corresponding function pointer by passing it to `lookup_decode_range_func_ptr()`. Removing function pointers like `decode_range` makes it possible to represent chip data in a declarative format that does not have to be stored as C source code. BUG=b:242479049 BRANCH=none TEST=ninja && ninja test Signed-off-by: Nikolai Artemiev Change-Id: If6d08d414d3d1ddadc95ca1d407fc87c23ab543d Reviewed-on: https://review.coreboot.org/c/flashrom/+/67195 Reviewed-by: Edward O'Callaghan Reviewed-by: Felix Singer Tested-by: build bot (Jenkins) --- include/flash.h | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'include') diff --git a/include/flash.h b/include/flash.h index 633601db..32290e4d 100644 --- a/include/flash.h +++ b/include/flash.h @@ -211,6 +211,12 @@ struct reg_bit_info { struct wp_bits; +enum decode_range_func { + NO_DECODE_RANGE_FUNC = 0, /* 0 indicates no range decode funciton is set. */ + DECODE_RANGE_SPI25 = 1, +}; +typedef void (decode_range_func_t)(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len); + struct flashchip { const char *vendor; const char *name; @@ -321,9 +327,11 @@ struct flashchip { struct reg_bit_info wps; } reg_bits; - /* Function that takes a set of WP config bits (e.g. BP, SEC, TB, etc) */ - /* and determines what protection range they select. */ - void (*decode_range)(size_t *start, size_t *len, const struct wp_bits *, size_t chip_len); + /* + * Function that takes a set of WP config bits (e.g. BP, SEC, TB, etc) + * and determines what protection range they select. + */ + enum decode_range_func decode_range; }; typedef int (*chip_restore_fn_cb_t)(struct flashctx *flash, uint8_t status); -- cgit v1.2.3