From 0c774d6b6a075f37f21ca9c3506141cb0d4ae34b Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Wed, 23 Nov 2022 22:36:53 +1100 Subject: 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 Reviewed-on: https://review.coreboot.org/c/flashrom/+/69933 Tested-by: build bot (Jenkins) Reviewed-by: Sam McNally Reviewed-by: Anastasia Klimchuk --- 82802ab.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to '82802ab.c') diff --git a/82802ab.c b/82802ab.c index 90c9cf0d..a440bd45 100644 --- a/82802ab.c +++ b/82802ab.c @@ -142,7 +142,7 @@ int write_82802ab(struct flashctx *flash, const uint8_t *src, unsigned int start return 0; } -int unlock_28f004s5(struct flashctx *flash) +static int unlock_28f004s5(struct flashctx *flash) { chipaddr bios = flash->virtual_memory; uint8_t mcfg, bcfg; @@ -195,7 +195,7 @@ int unlock_28f004s5(struct flashctx *flash) return 0; } -int unlock_lh28f008bjt(struct flashctx *flash) +static int unlock_lh28f008bjt(struct flashctx *flash) { chipaddr bios = flash->virtual_memory; uint8_t mcfg, bcfg; @@ -249,3 +249,12 @@ int unlock_lh28f008bjt(struct flashctx *flash) return 0; } + +blockprotect_func_t *lookup_82802ab_blockprotect_func_ptr(const struct flashchip *const chip) +{ + switch (chip->unlock) { + case UNLOCK_28F004S5: return unlock_28f004s5; + case UNLOCK_LH28F008BJT: return unlock_lh28f008bjt; + default: return NULL; /* fallthough */ + }; +} -- cgit v1.2.3