Skip to content

Commit

Permalink
drivers/: Make 'internal_delay' the default unless defined
Browse files Browse the repository at this point in the history
Drop the explicit need to specify the default 'internal_delay'
callback function pointer in the programmer_entry struct.
This is a reasonable default for every other driver in the
tree with only the two exceptions of ch341a_spi.c and serprog.c.

Thus this simplifies driver development.

Change-Id: I17460bc2c0aebcbb48c8dfa052b260991525cc49
Signed-off-by: Edward O'Callaghan <[email protected]>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67391
Reviewed-by: Peter Marheine <[email protected]>
Reviewed-by: Angel Pons <[email protected]>
Reviewed-by: Thomas Heijligen <[email protected]>
Reviewed-by: Felix Singer <[email protected]>
Reviewed-by: Nikolai Artemiev <[email protected]>
Tested-by: build bot (Jenkins) <[email protected]>
  • Loading branch information
quasisec authored and felixsinger committed Sep 27, 2022
1 parent 3d79051 commit 4b503be
Show file tree
Hide file tree
Showing 37 changed files with 6 additions and 42 deletions.
1 change: 0 additions & 1 deletion atahpt.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,5 +122,4 @@ const struct programmer_entry programmer_atahpt = {
.init = atahpt_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion atapromise.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,5 +186,4 @@ const struct programmer_entry programmer_atapromise = {
.init = atapromise_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion atavia.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,5 +191,4 @@ const struct programmer_entry programmer_atavia = {
.init = atavia_init,
.map_flash_region = atavia_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion buspirate_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -716,5 +716,4 @@ const struct programmer_entry programmer_buspirate_spi = {
.init = buspirate_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion dediprog.c
Original file line number Diff line number Diff line change
Expand Up @@ -1321,5 +1321,4 @@ const struct programmer_entry programmer_dediprog = {
.init = dediprog_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion developerbox_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -195,5 +195,4 @@ const struct programmer_entry programmer_developerbox = {
.init = developerbox_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion digilent_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -470,5 +470,4 @@ const struct programmer_entry programmer_digilent_spi = {
.init = digilent_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion drkaiser.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,5 +124,4 @@ const struct programmer_entry programmer_drkaiser = {
.init = drkaiser_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion dummyflasher.c
Original file line number Diff line number Diff line change
Expand Up @@ -1426,5 +1426,4 @@ const struct programmer_entry programmer_dummy = {
.init = dummy_init,
.map_flash_region = dummy_map,
.unmap_flash_region = dummy_unmap,
.delay = internal_delay,
};
12 changes: 6 additions & 6 deletions flashrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,12 @@ void programmer_unmap_flash_region(void *virt_addr, size_t len)

void programmer_delay(unsigned int usecs)
{
if (usecs > 0)
programmer->delay(usecs);
if (usecs > 0) {
if (programmer->delay)
programmer->delay(usecs);
else
internal_delay(usecs);
}
}

int read_memmapped(struct flashctx *flash, uint8_t *buf, unsigned int start,
Expand Down Expand Up @@ -1419,10 +1423,6 @@ int selfcheck(void)
msg_gerr("Programmer %s does not have a valid init function!\n", p->name);
ret = 1;
}
if (p->delay == NULL) {
msg_gerr("Programmer %s does not have a valid delay 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;
Expand Down
1 change: 0 additions & 1 deletion ft2232_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -713,5 +713,4 @@ const struct programmer_entry programmer_ft2232_spi = {
.init = ft2232_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion gfxnvidia.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,5 +152,4 @@ const struct programmer_entry programmer_gfxnvidia = {
.init = gfxnvidia_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -349,5 +349,4 @@ const struct programmer_entry programmer_internal = {
.init = internal_init,
.map_flash_region = physmap,
.unmap_flash_region = physunmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion it8212.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,5 +113,4 @@ const struct programmer_entry programmer_it8212 = {
.init = it8212_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion jlink_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -538,5 +538,4 @@ const struct programmer_entry programmer_jlink_spi = {
.devs.note = "SEGGER J-Link and compatible devices\n",
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion linux_mtd.c
Original file line number Diff line number Diff line change
Expand Up @@ -559,5 +559,4 @@ const struct programmer_entry programmer_linux_mtd = {
.init = linux_mtd_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion linux_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,5 +253,4 @@ const struct programmer_entry programmer_linux_spi = {
.init = linux_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion mediatek_i2c_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -544,5 +544,4 @@ const struct programmer_entry programmer_mediatek_i2c_spi = {
.init = mediatek_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion mstarddc_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,4 @@ const struct programmer_entry programmer_mstarddc_spi = {
.init = mstarddc_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion ni845x_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -637,5 +637,4 @@ const struct programmer_entry programmer_ni845x_spi = {
.init = ni845x_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion nic3com.c
Original file line number Diff line number Diff line change
Expand Up @@ -170,5 +170,4 @@ const struct programmer_entry programmer_nic3com = {
.init = nic3com_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion nicintel.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,4 @@ const struct programmer_entry programmer_nicintel = {
.init = nicintel_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion nicintel_eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,5 +540,4 @@ const struct programmer_entry programmer_nicintel_eeprom = {
.init = nicintel_ee_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion nicintel_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,5 +339,4 @@ const struct programmer_entry programmer_nicintel_spi = {
.init = nicintel_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion nicnatsemi.c
Original file line number Diff line number Diff line change
Expand Up @@ -129,5 +129,4 @@ const struct programmer_entry programmer_nicnatsemi = {
.init = nicnatsemi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion nicrealtek.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,4 @@ const struct programmer_entry programmer_nicrealtek = {
.init = nicrealtek_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion ogp_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,5 +180,4 @@ const struct programmer_entry programmer_ogp_spi = {
.init = ogp_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion parade_lspcon.c
Original file line number Diff line number Diff line change
Expand Up @@ -509,5 +509,4 @@ const struct programmer_entry programmer_parade_lspcon = {
.init = parade_lspcon_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion pickit2_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -513,5 +513,4 @@ const struct programmer_entry programmer_pickit2_spi = {
.init = pickit2_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion pony_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,5 +274,4 @@ const struct programmer_entry programmer_pony_spi = {
.init = pony_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion raiden_debug_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1651,5 +1651,4 @@ const struct programmer_entry programmer_raiden_debug_spi = {
.init = raiden_debug_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion rayer_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,5 +331,4 @@ const struct programmer_entry programmer_rayer_spi = {
.init = rayer_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion realtek_mst_i2c_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -546,5 +546,4 @@ const struct programmer_entry programmer_realtek_mst_i2c_spi = {
.init = realtek_mst_i2c_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion satamv.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,5 +213,4 @@ const struct programmer_entry programmer_satamv = {
.init = satamv_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion satasii.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,4 @@ const struct programmer_entry programmer_satasii = {
.init = satasii_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion stlinkv3_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -558,5 +558,4 @@ const struct programmer_entry programmer_stlinkv3_spi = {
.init = stlinkv3_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};
1 change: 0 additions & 1 deletion usbblaster_spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,5 +234,4 @@ const struct programmer_entry programmer_usbblaster_spi = {
.init = usbblaster_spi_init,
.map_flash_region = fallback_map,
.unmap_flash_region = fallback_unmap,
.delay = internal_delay,
};

0 comments on commit 4b503be

Please sign in to comment.