mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-02 22:43:17 +02:00
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. Change-Id: I5ea7bd68f7ae2cd4af9902ef07255ab6ce0bfdb3 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/67404 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Felix Singer <felixsinger@posteo.net> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:

committed by
Angel Pons

parent
7e8d17a8bd
commit
67d5015617
19
flashrom.c
19
flashrom.c
@ -205,7 +205,11 @@ int programmer_shutdown(void)
|
||||
|
||||
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;
|
||||
@ -213,7 +217,10 @@ void *programmer_map_flash_region(const char *descr, uintptr_t phys_addr, size_t
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -1423,14 +1430,6 @@ int selfcheck(void)
|
||||
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
|
||||
|
Reference in New Issue
Block a user