Anastasia Klimchuk has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/51761 )
Change subject: Accept shutdown function in register_master ......................................................................
Accept shutdown function in register_master
The patch is the first in the series of many with the goal to improve API for registering masters. This one only changes the signature of functions, but everything still works as before.
TEST=builds
Change-Id: I1704ddafc56e1393613a7ea077e40c36911cfac8 Signed-off-by: Anastasia Klimchuk aklm@chromium.org --- M atavia.c M bitbang_spi.c M buspirate_spi.c M ch341a_spi.c M dediprog.c M digilent_spi.c M drkaiser.c M dummyflasher.c M ene_lpc.c M ft2232_spi.c M gfxnvidia.c M ichspi.c M internal.c M it8212.c M it85spi.c M it87spi.c M linux_mtd.c M linux_spi.c M mec1308.c M nic3com.c M nicintel.c M nicintel_eeprom.c M nicrealtek.c M opaque.c M pickit2_spi.c M programmer.c M programmer.h M raiden_debug_spi.c M satamv.c M satasii.c M sb600spi.c M serprog.c M spi.c M stlinkv3_spi.c M usbblaster_spi.c M wbsio_spi.c 36 files changed, 77 insertions(+), 52 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/61/51761/1
diff --git a/atavia.c b/atavia.c index b407a30..6a32b07 100644 --- a/atavia.c +++ b/atavia.c @@ -160,7 +160,7 @@ return 1; }
- register_par_master(&lpc_master_atavia, BUS_LPC); + register_par_master(&lpc_master_atavia, BUS_LPC, NULL, NULL);
return 0; } diff --git a/bitbang_spi.c b/bitbang_spi.c index b12d81a..b96e652 100644 --- a/bitbang_spi.c +++ b/bitbang_spi.c @@ -162,7 +162,7 @@ struct bitbang_spi_master_data *data = calloc(1, sizeof(struct bitbang_spi_master_data)); data->mst = master; mst.data = data; - register_spi_master(&mst); + register_spi_master(&mst, NULL, NULL); register_shutdown(bitbang_spi_shutdown, data);
/* Only mess with the bus if we're sure nobody else uses it. */ diff --git a/buspirate_spi.c b/buspirate_spi.c index eee8daa..648ec91 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -655,7 +655,7 @@ return 1; }
- register_spi_master(&spi_master_buspirate); + register_spi_master(&spi_master_buspirate, NULL, NULL);
return 0; } diff --git a/ch341a_spi.c b/ch341a_spi.c index 84cc3fe..69dc8e9 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -506,7 +506,7 @@ goto dealloc_transfers;
register_shutdown(ch341a_spi_shutdown, NULL); - register_spi_master(&spi_master_ch341a_spi); + register_spi_master(&spi_master_ch341a_spi, NULL, NULL);
return 0;
diff --git a/dediprog.c b/dediprog.c index c50e374..66f0a1d 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1273,7 +1273,7 @@ if (protocol() == PROTOCOL_V2) spi_master_dediprog.features |= SPI_MASTER_4BA;
- if (register_spi_master(&spi_master_dediprog) || dediprog_set_leds(LED_NONE)) + if (register_spi_master(&spi_master_dediprog, NULL, NULL) || dediprog_set_leds(LED_NONE)) return 1;
return 0; diff --git a/digilent_spi.c b/digilent_spi.c index 0f7a9da..4001c96 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -445,7 +445,7 @@ goto close_handle;
register_shutdown(digilent_spi_shutdown, NULL); - register_spi_master(&spi_master_digilent_spi); + register_spi_master(&spi_master_digilent_spi, NULL, NULL);
return 0;
diff --git a/drkaiser.c b/drkaiser.c index ac49df3..f92dc36 100644 --- a/drkaiser.c +++ b/drkaiser.c @@ -77,7 +77,7 @@ return 1;
max_rom_decode.parallel = 128 * 1024; - register_par_master(&par_master_drkaiser, BUS_PARALLEL); + register_par_master(&par_master_drkaiser, BUS_PARALLEL, NULL, NULL);
return 0; } diff --git a/dummyflasher.c b/dummyflasher.c index 5190282..ca814a0 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -1027,9 +1027,11 @@ } if (dummy_buses_supported & (BUS_PARALLEL | BUS_LPC | BUS_FWH)) register_par_master(&par_master_dummy, - dummy_buses_supported & (BUS_PARALLEL | BUS_LPC | BUS_FWH)); + dummy_buses_supported & (BUS_PARALLEL | BUS_LPC | BUS_FWH), + NULL, + NULL); if (dummy_buses_supported & BUS_SPI) - register_spi_master(&spi_master_dummyflasher); + register_spi_master(&spi_master_dummyflasher, NULL, NULL);
return 0; } diff --git a/ene_lpc.c b/ene_lpc.c index 56d6580..4cf63a8 100644 --- a/ene_lpc.c +++ b/ene_lpc.c @@ -583,7 +583,7 @@
internal_buses_supported |= BUS_LPC; spi_master_ene.data = ctx_data; - register_spi_master(&spi_master_ene); + register_spi_master(&spi_master_ene, NULL, NULL); msg_pdbg("%s: successfully initialized ene\n", __func__);
ene_probe_spi_flash_exit: diff --git a/ft2232_spi.c b/ft2232_spi.c index 1fb795b..f3734c5 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -603,7 +603,7 @@ }
register_shutdown(ft2232_shutdown, ftdic); - register_spi_master(&spi_master_ft2232); + register_spi_master(&spi_master_ft2232, NULL, NULL);
return 0;
diff --git a/gfxnvidia.c b/gfxnvidia.c index d8ea4d6..51bbf22 100644 --- a/gfxnvidia.c +++ b/gfxnvidia.c @@ -103,7 +103,7 @@
/* Write/erase doesn't work. */ programmer_may_write = 0; - register_par_master(&par_master_gfxnvidia, BUS_PARALLEL); + register_par_master(&par_master_gfxnvidia, BUS_PARALLEL, NULL, NULL);
return 0; } diff --git a/ichspi.c b/ichspi.c index e45b39a..a328106 100644 --- a/ichspi.c +++ b/ichspi.c @@ -1812,7 +1812,7 @@ } ich_init_opcodes(ich_gen); ich_set_bbar(0, ich_gen); - register_spi_master(&spi_master_ich7); + register_spi_master(&spi_master_ich7, NULL, NULL); break; case CHIPSET_ICH8: default: /* Future version might behave the same */ @@ -2039,9 +2039,9 @@ } hwseq_data.size_comp1 = tmpi;
- register_opaque_master(&opaque_master_ich_hwseq); + register_opaque_master(&opaque_master_ich_hwseq, NULL, NULL); } else { - register_spi_master(&spi_master_ich9); + register_spi_master(&spi_master_ich9, NULL, NULL); } break; } @@ -2071,7 +2071,7 @@ /* Not sure if it speaks all these bus protocols. */ internal_buses_supported &= BUS_LPC | BUS_FWH; ich_generation = CHIPSET_ICH7; - register_spi_master(&spi_master_via); + register_spi_master(&spi_master_via, NULL, NULL);
msg_pdbg("0x00: 0x%04x (SPIS)\n", mmio_readw(ich_spibar + 0)); msg_pdbg("0x02: 0x%04x (SPIC)\n", mmio_readw(ich_spibar + 2)); diff --git a/internal.c b/internal.c index bdbe32d..853e79f 100644 --- a/internal.c +++ b/internal.c @@ -335,7 +335,7 @@ #endif /* IS_X86 */
if (internal_buses_supported & BUS_NONSPI) - register_par_master(&par_master_internal, internal_buses_supported); + register_par_master(&par_master_internal, internal_buses_supported, NULL, NULL);
/* Report if a non-whitelisted laptop is detected that likely uses a legacy bus. */ if (is_laptop && !laptop_ok) { diff --git a/it8212.c b/it8212.c index ac53a6f..ba140e5 100644 --- a/it8212.c +++ b/it8212.c @@ -67,7 +67,7 @@ rpci_write_long(dev, PCI_ROM_ADDRESS, io_base_addr | 0x01);
max_rom_decode.parallel = IT8212_MEMMAP_SIZE; - register_par_master(&par_master_it8212, BUS_PARALLEL); + register_par_master(&par_master_it8212, BUS_PARALLEL, NULL, NULL); return 0; }
diff --git a/it85spi.c b/it85spi.c index 9817c2a..640e65f 100644 --- a/it85spi.c +++ b/it85spi.c @@ -366,7 +366,7 @@ * a debug message about it. */ /* Set this as SPI controller. */ - register_spi_master(&spi_master_it85xx); + register_spi_master(&spi_master_it85xx, NULL, NULL);
return 0; } diff --git a/it87spi.c b/it87spi.c index 868b479..b0933ae 100644 --- a/it87spi.c +++ b/it87spi.c @@ -426,7 +426,7 @@ if (internal_buses_supported & BUS_SPI) msg_pdbg("Overriding chipset SPI with IT87 SPI.\n"); /* FIXME: Add the SPI bus or replace the other buses with it? */ - register_spi_master(&spi_master_it87xx); + register_spi_master(&spi_master_it87xx, NULL, NULL); return 0; }
diff --git a/linux_mtd.c b/linux_mtd.c index 22702e9..d0bec4e 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -404,7 +404,7 @@ if (register_shutdown(linux_mtd_shutdown, NULL)) goto linux_mtd_init_exit;
- register_opaque_master(&programmer_linux_mtd); + register_opaque_master(&programmer_linux_mtd, NULL, NULL);
ret = 0; linux_mtd_init_exit: diff --git a/linux_spi.c b/linux_spi.c index bbd45f3..d693086 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -220,7 +220,7 @@ }
msg_pdbg("%s: max_kernel_buf_size: %zu\n", __func__, max_kernel_buf_size); - register_spi_master(&spi_master_linux); + register_spi_master(&spi_master_linux, NULL, NULL); return 0; }
diff --git a/mec1308.c b/mec1308.c index c4b34f5..17e73ed 100644 --- a/mec1308.c +++ b/mec1308.c @@ -511,7 +511,7 @@
internal_buses_supported |= BUS_LPC; /* for LPC <--> SPI bridging */ spi_master_mec1308.data = ctx_data; - register_spi_master(&spi_master_mec1308); + register_spi_master(&spi_master_mec1308, NULL, NULL); msg_pdbg("%s(): successfully initialized mec1308\n", __func__);
mec1308_init_exit: diff --git a/nic3com.c b/nic3com.c index b7b967a..403e2a0 100644 --- a/nic3com.c +++ b/nic3com.c @@ -120,7 +120,7 @@ return 1;
max_rom_decode.parallel = 128 * 1024; - register_par_master(&par_master_nic3com, BUS_PARALLEL); + register_par_master(&par_master_nic3com, BUS_PARALLEL, NULL, NULL);
return 0; } diff --git a/nicintel.c b/nicintel.c index 4672890..85100aa 100644 --- a/nicintel.c +++ b/nicintel.c @@ -99,7 +99,7 @@ pci_rmmio_writew(0x0001, nicintel_control_bar + CSR_FCR);
max_rom_decode.parallel = NICINTEL_MEMMAP_SIZE; - register_par_master(&par_master_nicintel, BUS_PARALLEL); + register_par_master(&par_master_nicintel, BUS_PARALLEL, NULL, NULL);
return 0; } diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c index 4d45f79..47c2505 100644 --- a/nicintel_eeprom.c +++ b/nicintel_eeprom.c @@ -486,7 +486,7 @@ return 1; }
- return register_opaque_master(&opaque_master_nicintel_ee_82580); + return register_opaque_master(&opaque_master_nicintel_ee_82580, NULL, NULL); } else { nicintel_eebar = rphysmap("Intel i210 NIC w/ emulated EEPROM", io_base_addr + 0x12000, MEMMAP_SIZE); @@ -496,7 +496,7 @@ if (register_shutdown(nicintel_ee_shutdown_i210, NULL)) return 1;
- return register_opaque_master(&opaque_master_nicintel_ee_i210); + return register_opaque_master(&opaque_master_nicintel_ee_i210, NULL, NULL); }
return 1; diff --git a/nicrealtek.c b/nicrealtek.c index 5454b63..07468e3 100644 --- a/nicrealtek.c +++ b/nicrealtek.c @@ -86,7 +86,7 @@ if (register_shutdown(nicrealtek_shutdown, NULL)) return 1;
- register_par_master(&par_master_nicrealtek, BUS_PARALLEL); + register_par_master(&par_master_nicrealtek, BUS_PARALLEL, NULL, NULL);
return 0; } diff --git a/opaque.c b/opaque.c index 276934f..5efb56c 100644 --- a/opaque.c +++ b/opaque.c @@ -46,7 +46,9 @@ return flash->mst->opaque.erase(flash, blockaddr, blocklen); }
-int register_opaque_master(const struct opaque_master *mst) +int register_opaque_master(const struct opaque_master *mst, + int (*shutdown_function) (void *data), + void *data) { struct registered_master rmst;
@@ -58,5 +60,5 @@ } rmst.buses_supported = BUS_PROG; rmst.opaque = *mst; - return register_master(&rmst); + return register_master(&rmst, shutdown_function, data); } diff --git a/pickit2_spi.c b/pickit2_spi.c index 0bc17af..5ef2f47 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -485,7 +485,7 @@ return 1; }
- register_spi_master(&spi_master_pickit2); + register_spi_master(&spi_master_pickit2, NULL, NULL);
return 0; } diff --git a/programmer.c b/programmer.c index bee60e3..7ff3d1a 100644 --- a/programmer.c +++ b/programmer.c @@ -81,7 +81,9 @@ }
int register_par_master(const struct par_master *mst, - const enum chipbustype buses) + const enum chipbustype buses, + int (*shutdown_function) (void *data), + void *data) { struct registered_master rmst; if (!mst->chip_writeb || !mst->chip_writew || !mst->chip_writel || @@ -95,7 +97,7 @@
rmst.buses_supported = buses; rmst.par = *mst; - return register_master(&rmst); + return register_master(&rmst, shutdown_function, data); }
/* The limit of 4 is totally arbitrary. */ @@ -103,8 +105,20 @@ struct registered_master registered_masters[MASTERS_MAX]; int registered_master_count = 0;
-/* This function copies the struct registered_master parameter. */ -int register_master(const struct registered_master *mst) +/* + * This function copies the struct registered_master parameter. + * + * TODO: implement registering a shutdown function for the master. + * + * @param shutdown_function to be executed at shutdown flow. If not needed + * set shutdown_function=NULL, in this case data is ignored + * @param data pointer to a data used by said function. If data is not + * needed set data=NULL + * + * */ +int register_master(const struct registered_master *mst, + int (*shutdown_function) (void *data), + void *data) { if (registered_master_count >= MASTERS_MAX) { msg_perr("Tried to register more than %i master " diff --git a/programmer.h b/programmer.h index 29a100b..0d8371b 100644 --- a/programmer.h +++ b/programmer.h @@ -643,7 +643,7 @@ int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len); int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); int default_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len); -int register_spi_master(const struct spi_master *mst); +int register_spi_master(const struct spi_master *mst, int (*shutdown_function) (void *data), void *data);
/* The following enum is needed by ich_descriptor_tool and ich* code as well as in chipset_enable.c. */ enum ich_chipset { @@ -724,7 +724,7 @@ int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen); void *data; }; -int register_opaque_master(const struct opaque_master *mst); +int register_opaque_master(const struct opaque_master *mst, int (*shutdown_function) (void *data), void *data);
/* programmer.c */ void *fallback_map(const char *descr, uintptr_t phys_addr, size_t len); @@ -746,7 +746,10 @@ void (*chip_readn) (const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len); void *data; }; -int register_par_master(const struct par_master *mst, const enum chipbustype buses); +int register_par_master(const struct par_master *mst, + const enum chipbustype buses, + int (*shutdown_function) (void *data), + void *data); struct registered_master { enum chipbustype buses_supported; union { @@ -757,7 +760,9 @@ }; extern struct registered_master registered_masters[]; extern int registered_master_count; -int register_master(const struct registered_master *mst); +int register_master(const struct registered_master *mst, + int (*shutdown_function) (void *data), + void *data);
/* serprog.c */ #if CONFIG_SERPROG == 1 diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index bd7c054..6c97290 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1614,7 +1614,7 @@ return SPI_GENERIC_ERROR; }
- register_spi_master(spi_config); + register_spi_master(spi_config, NULL, NULL); register_shutdown(raiden_debug_spi_shutdown, spi_config);
return 0; diff --git a/satamv.c b/satamv.c index 31265ea..da0091a 100644 --- a/satamv.c +++ b/satamv.c @@ -148,7 +148,7 @@ /* 512 kByte with two 8-bit latches, and * 4 MByte with additional 3-bit latch. */ max_rom_decode.parallel = 4 * 1024 * 1024; - register_par_master(&par_master_satamv, BUS_PARALLEL); + register_par_master(&par_master_satamv, BUS_PARALLEL, NULL, NULL);
return 0; } diff --git a/satasii.c b/satasii.c index 8a0938d..7560d4c 100644 --- a/satasii.c +++ b/satasii.c @@ -100,7 +100,7 @@ if ((id != 0x0680) && (!(pci_mmio_readl(sii_bar) & (1 << 26)))) msg_pwarn("Warning: Flash seems unconnected.\n");
- register_par_master(&par_master_satasii, BUS_PARALLEL); + register_par_master(&par_master_satasii, BUS_PARALLEL, NULL, NULL);
return 0; } diff --git a/sb600spi.c b/sb600spi.c index ef9da4b..e523168 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -786,11 +786,11 @@
/* Starting with Yangtze the SPI controller got a different interface with a much bigger buffer. */ if (amd_gen < CHIPSET_YANGTZE) - register_spi_master(&spi_master_sb600); + register_spi_master(&spi_master_sb600, NULL, NULL); else if (amd_gen == CHIPSET_YANGTZE) - register_spi_master(&spi_master_yangtze); + register_spi_master(&spi_master_yangtze, NULL, NULL); else - register_spi_master(&spi_master_promontory); + register_spi_master(&spi_master_promontory, NULL, NULL);
return 0; } diff --git a/serprog.c b/serprog.c index d583a40..e2bf419 100644 --- a/serprog.c +++ b/serprog.c @@ -883,9 +883,9 @@ sp_streamed_transmit_bytes = 0; sp_opbuf_usage = 0; if (serprog_buses_supported & BUS_SPI) - register_spi_master(&spi_master_serprog); + register_spi_master(&spi_master_serprog, NULL, NULL); if (serprog_buses_supported & BUS_NONSPI) - register_par_master(&par_master_serprog, serprog_buses_supported & BUS_NONSPI); + register_par_master(&par_master_serprog, serprog_buses_supported & BUS_NONSPI, NULL, NULL); return 0; }
diff --git a/spi.c b/spi.c index aed2a92..000c674 100644 --- a/spi.c +++ b/spi.c @@ -131,7 +131,9 @@ return flash->mst->spi.write_aai(flash, buf, start, len); }
-int register_spi_master(const struct spi_master *mst) +int register_spi_master(const struct spi_master *mst, + int (*shutdown_function) (void *data), + void *data) { struct registered_master rmst;
@@ -148,5 +150,5 @@
rmst.buses_supported = BUS_SPI; rmst.spi = *mst; - return register_master(&rmst); + return register_master(&rmst, shutdown_function, data); } diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 7e8336e..5af9695 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -509,7 +509,7 @@ if (register_shutdown(stlinkv3_spi_shutdown, NULL)) goto err_exit;
- if (register_spi_master(&spi_programmer_stlinkv3)) + if (register_spi_master(&spi_programmer_stlinkv3, NULL, NULL)) goto err_exit;
return 0; diff --git a/usbblaster_spi.c b/usbblaster_spi.c index 58a8a0e..8699292 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -113,7 +113,7 @@ return -1; }
- register_spi_master(&spi_master_usbblaster); + register_spi_master(&spi_master_usbblaster, NULL, NULL); return 0; }
diff --git a/wbsio_spi.c b/wbsio_spi.c index 632ff72..8b51995 100644 --- a/wbsio_spi.c +++ b/wbsio_spi.c @@ -216,7 +216,7 @@
register_shutdown(wbsio_spi_shutdown, data); spi_master_wbsio.data = data; - register_spi_master(&spi_master_wbsio); + register_spi_master(&spi_master_wbsio, NULL, NULL);
return 0; }