drivers/: Make 'fallback_{un}map' the default unless defined
Drop the explicit need to specify the default 'fallback_{un}map'
callback function pointer from the 'programmer_entry' struct.
This is a reasonable default for every other driver in the tree
with only a select few exceptions [atavia, serprog, dummyflasher
and internal].
Thus this simplifies driver development and paves way
to remove the 'programmer' global handle.
flashrom-stable: Updated `dirtyjtag_spi` which was added earlier.
Change-Id: I5ea7bd68f7ae2cd4af9902ef07255ab6ce0bfdb3
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/67404
Original-Reviewed-by: Felix Singer <felixsinger@posteo.net>
Original-Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Original-Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72360
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
diff --git a/flashrom.c b/flashrom.c
index c434cff..40472ec 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -209,7 +209,11 @@
void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t len)
{
- void *ret = programmer->map_flash_region(descr, phys_addr, len);
+ void *ret;
+ if (programmer->map_flash_region)
+ ret = programmer->map_flash_region(descr, phys_addr, len);
+ else
+ ret = fallback_map(descr, phys_addr, len);
msg_gspew("%s: mapping %s from 0x%0*" PRIxPTR " to 0x%0*" PRIxPTR "\n",
__func__, descr, PRIxPTR_WIDTH, phys_addr, PRIxPTR_WIDTH, (uintptr_t) ret);
return ret;
@@ -217,7 +221,10 @@
void programmer_unmap_flash_region(void *virt_addr, size_t len)
{
- programmer->unmap_flash_region(virt_addr, len);
+ if (programmer->unmap_flash_region)
+ programmer->unmap_flash_region(virt_addr, len);
+ else
+ fallback_unmap(virt_addr, len);
msg_gspew("%s: unmapped 0x%0*" PRIxPTR "\n", __func__, PRIxPTR_WIDTH, (uintptr_t)virt_addr);
}
@@ -1420,14 +1427,6 @@
msg_gerr("Programmer %s does not have a valid init function!\n", p->name);
ret = 1;
}
- if (p->map_flash_region == NULL) {
- msg_gerr("Programmer %s does not have a valid map_flash_region function!\n", p->name);
- ret = 1;
- }
- if (p->unmap_flash_region == NULL) {
- msg_gerr("Programmer %s does not have a valid unmap_flash_region function!\n", p->name);
- ret = 1;
- }
}
/* It would be favorable if we could check for the correct layout (especially termination) of various