Attention is currently required from: Nikolai Artemiev, Peter Marheine.
Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/67404 )
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. This is a reasonable default for every other driver in the tree with only a select few exceptions.
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 --- 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, 26 insertions(+), 79 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/04/67404/1
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 9a83820..ffa4698 100644 --- a/atapromise.c +++ b/atapromise.c @@ -191,5 +191,4 @@ .devs.dev = ata_promise, .init = atapromise_init, .map_flash_region = atapromise_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/atavia.c b/atavia.c index 2148147..a0a0547 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 041b8db..501f6b0 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -713,6 +713,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 49f794e..61e007c 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -525,6 +525,4 @@ .type = USB, .devs.dev = devs_ch341a_spi, .init = ch341a_spi_init, - .map_flash_region = fallback_map, - .unmap_flash_region = fallback_unmap, }; diff --git a/dediprog.c b/dediprog.c index 092e8c2..b4279d8 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 3ad07da..ffb5bf4 100644 --- a/flashrom.c +++ b/flashrom.c @@ -195,7 +195,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; @@ -203,7 +207,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); }
@@ -1417,14 +1424,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 5a6177c..cee7330 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -710,6 +710,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 ca432ac..e4a91e8 100644 --- a/gfxnvidia.c +++ b/gfxnvidia.c @@ -149,6 +149,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 dfcfd05..720f67a 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -556,6 +556,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 fab002f..70e6426 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -254,6 +254,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 1efcbe0..1e1f2e8 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 a1668c3..cd6fcb1 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -271,6 +271,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 66164fb..7a8f250 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1648,6 +1648,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 a8c31b6..198c823 100644 --- a/serprog.c +++ b/serprog.c @@ -967,5 +967,4 @@ .devs.note = "All programmer devices speaking the serprog protocol\n", .init = serprog_init, .map_flash_region = serprog_map, - .unmap_flash_region = fallback_unmap, }; 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, };