Angel Pons has submitted this change. ( https://review.coreboot.org/c/flashrom/+/67404 )
(
4 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: drivers/: Make 'fallback_{un}map' the default unless defined ......................................................................
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 --- M atahpt.c M atapromise.c M atavia.c M buspirate_spi.c M ch341a_spi.c M dediprog.c M developerbox_spi.c M digilent_spi.c M drkaiser.c M flashrom.c M ft2232_spi.c M gfxnvidia.c M it8212.c M jlink_spi.c M linux_mtd.c M linux_spi.c M mediatek_i2c_spi.c M mstarddc_spi.c M ni845x_spi.c M nic3com.c M nicintel.c M nicintel_eeprom.c M nicintel_spi.c M nicnatsemi.c M nicrealtek.c M ogp_spi.c M parade_lspcon.c M pickit2_spi.c M pony_spi.c M raiden_debug_spi.c M rayer_spi.c M realtek_mst_i2c_spi.c M satamv.c M satasii.c M serprog.c M stlinkv3_spi.c M usbblaster_spi.c 37 files changed, 33 insertions(+), 80 deletions(-)
Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Angel Pons: Looks good to me, but someone else must approve Anastasia Klimchuk: Looks good to me, approved
diff --git a/atahpt.c b/atahpt.c index fa69137..89b44c2 100644 --- a/atahpt.c +++ b/atahpt.c @@ -120,6 +120,4 @@ .type = PCI, .devs.dev = ata_hpt, .init = atahpt_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/atapromise.c b/atapromise.c index 5de0921..625eb83 100644 --- a/atapromise.c +++ b/atapromise.c @@ -184,6 +184,4 @@ .type = PCI, .devs.dev = ata_promise, .init = atapromise_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/atavia.c b/atavia.c index a0be396..66bca65 100644 --- a/atavia.c +++ b/atavia.c @@ -190,5 +190,4 @@ .devs.dev = ata_via, .init = atavia_init, .map_flash_region = atavia_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/buspirate_spi.c b/buspirate_spi.c index 121c7e5..dbaac4e 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -714,6 +714,4 @@ /* FIXME */ .devs.note = "Dangerous Prototypes Bus Pirate\n", .init = buspirate_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/ch341a_spi.c b/ch341a_spi.c index 48c6420..294a6a6 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -525,7 +525,5 @@ .type = USB, .devs.dev = devs_ch341a_spi, .init = ch341a_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, .delay = ch341a_spi_delay, }; diff --git a/dediprog.c b/dediprog.c index 99c91e0..ae9e448 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1319,6 +1319,4 @@ .type = USB, .devs.dev = devs_dediprog, .init = dediprog_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/developerbox_spi.c b/developerbox_spi.c index 04957a3..64b7e8a 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -193,6 +193,4 @@ .type = USB, .devs.dev = devs_developerbox_spi, .init = developerbox_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/digilent_spi.c b/digilent_spi.c index 85f3884..6575cbf 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -468,6 +468,4 @@ .type = USB, .devs.dev = devs_digilent_spi, .init = digilent_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/drkaiser.c b/drkaiser.c index 039e686..96f2c99 100644 --- a/drkaiser.c +++ b/drkaiser.c @@ -122,6 +122,4 @@ .type = PCI, .devs.dev = drkaiser_pcidev, .init = drkaiser_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/flashrom.c b/flashrom.c index 3328a71..f74b79a 100644 --- a/flashrom.c +++ b/flashrom.c @@ -205,7 +205,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; @@ -213,7 +217,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); }
@@ -1423,14 +1430,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 diff --git a/ft2232_spi.c b/ft2232_spi.c index 6d7aa6a..aec21bc 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -711,6 +711,4 @@ .type = USB, .devs.dev = devs_ft2232spi, .init = ft2232_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/gfxnvidia.c b/gfxnvidia.c index cab408c..1d484ea 100644 --- a/gfxnvidia.c +++ b/gfxnvidia.c @@ -150,6 +150,4 @@ .type = PCI, .devs.dev = gfx_nvidia, .init = gfxnvidia_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/it8212.c b/it8212.c index 9b4a263..8fe2b59 100644 --- a/it8212.c +++ b/it8212.c @@ -111,6 +111,4 @@ .type = PCI, .devs.dev = devs_it8212, .init = it8212_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/jlink_spi.c b/jlink_spi.c index ef4d9ca..63d15b8 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -536,6 +536,4 @@ .type = OTHER, .init = jlink_spi_init, .devs.note = "SEGGER J-Link and compatible devices\n", - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/linux_mtd.c b/linux_mtd.c index 26244a8..b8aee06 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -557,6 +557,4 @@ .type = OTHER, .devs.note = "Device files /dev/mtd*\n", .init = linux_mtd_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/linux_spi.c b/linux_spi.c index b51d9e9..ee02304 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -251,6 +251,4 @@ .type = OTHER, .devs.note = "Device files /dev/spidev*.*\n", .init = linux_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/mediatek_i2c_spi.c b/mediatek_i2c_spi.c index 727f933..3aa9dd9 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -542,6 +542,4 @@ .type = OTHER, .devs.note = "Device files /dev/i2c-*\n", .init = mediatek_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/mstarddc_spi.c b/mstarddc_spi.c index 88a4afa..0c11717 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -255,6 +255,4 @@ .type = OTHER, .devs.note = "MSTAR DDC devices addressable via /dev/i2c-* on Linux.\n", .init = mstarddc_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/ni845x_spi.c b/ni845x_spi.c index b5cfc06..2750334 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -635,6 +635,4 @@ .type = OTHER, // choose other because NI-845x uses own USB implementation .devs.note = "National Instruments USB-845x\n", .init = ni845x_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/nic3com.c b/nic3com.c index 8fafef9..efba979 100644 --- a/nic3com.c +++ b/nic3com.c @@ -168,6 +168,4 @@ .type = PCI, .devs.dev = nics_3com, .init = nic3com_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/nicintel.c b/nicintel.c index fa91ff1..47edbb7 100644 --- a/nicintel.c +++ b/nicintel.c @@ -133,6 +133,4 @@ .type = PCI, .devs.dev = nics_intel, .init = nicintel_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c index 01f9075..a254420 100644 --- a/nicintel_eeprom.c +++ b/nicintel_eeprom.c @@ -538,6 +538,4 @@ .type = PCI, .devs.dev = nics_intel_ee, .init = nicintel_ee_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/nicintel_spi.c b/nicintel_spi.c index b99da53..2821d23 100644 --- a/nicintel_spi.c +++ b/nicintel_spi.c @@ -337,6 +337,4 @@ .type = PCI, .devs.dev = nics_intel_spi, .init = nicintel_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/nicnatsemi.c b/nicnatsemi.c index 7236d4d..efa879a 100644 --- a/nicnatsemi.c +++ b/nicnatsemi.c @@ -127,6 +127,4 @@ .type = PCI, .devs.dev = nics_natsemi, .init = nicnatsemi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/nicrealtek.c b/nicrealtek.c index c96f998..103ea9e 100644 --- a/nicrealtek.c +++ b/nicrealtek.c @@ -146,6 +146,4 @@ .type = PCI, .devs.dev = nics_realtek, .init = nicrealtek_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/ogp_spi.c b/ogp_spi.c index 52b1d4e..d85c823 100644 --- a/ogp_spi.c +++ b/ogp_spi.c @@ -178,6 +178,4 @@ .type = PCI, .devs.dev = ogp_spi, .init = ogp_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/parade_lspcon.c b/parade_lspcon.c index 72f7600..a50346e 100644 --- a/parade_lspcon.c +++ b/parade_lspcon.c @@ -507,6 +507,4 @@ .type = OTHER, .devs.note = "Device files /dev/i2c-*.\n", .init = parade_lspcon_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/pickit2_spi.c b/pickit2_spi.c index f550b4f..e8c80af 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -511,6 +511,4 @@ .type = USB, .devs.dev = devs_pickit2_spi, .init = pickit2_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/pony_spi.c b/pony_spi.c index 63359d2..3a85eeb 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -272,6 +272,4 @@ /* FIXME */ .devs.note = "Programmers compatible with SI-Prog, serbang or AJAWe\n", .init = pony_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index 9ded585..a2e5e84 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1649,6 +1649,4 @@ .type = USB, .devs.dev = devs_raiden, .init = raiden_debug_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/rayer_spi.c b/rayer_spi.c index cd7a066..8fdcc01 100644 --- a/rayer_spi.c +++ b/rayer_spi.c @@ -329,6 +329,4 @@ /* FIXME */ .devs.note = "RayeR parallel port programmer\n", .init = rayer_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index 9637eca..2a5d5ed 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -544,6 +544,4 @@ .type = OTHER, .devs.note = "Device files /dev/i2c-*.\n", .init = realtek_mst_i2c_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/satamv.c b/satamv.c index c3831d1..dcd53c7 100644 --- a/satamv.c +++ b/satamv.c @@ -211,6 +211,4 @@ .type = PCI, .devs.dev = satas_mv, .init = satamv_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/satasii.c b/satasii.c index 0f3311f..011562e 100644 --- a/satasii.c +++ b/satasii.c @@ -153,6 +153,4 @@ .type = PCI, .devs.dev = satas_sii, .init = satasii_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/serprog.c b/serprog.c index 57196a9..12d15d7 100644 --- a/serprog.c +++ b/serprog.c @@ -967,6 +967,5 @@ .devs.note = "All programmer devices speaking the serprog protocol\n", .init = serprog_init, .map_flash_region = serprog_map, - .unmap_flash_region = fallback_unmap, .delay = serprog_delay, }; diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index dcbed6d..9ae3df5 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -556,6 +556,4 @@ .type = USB, .devs.dev = devs_stlinkv3_spi, .init = stlinkv3_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/usbblaster_spi.c b/usbblaster_spi.c index c5914c4..5e2c020 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -232,6 +232,4 @@ .type = USB, .devs.dev = devs_usbblasterspi, .init = usbblaster_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, };