1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-06-30 21:52:36 +02:00

spi_master: Move shutdown function above spi_master struct

This patch prepares spi masters to use new API which allows to
register shutdown function in spi_master struct. See also later
patch in this chain, where spi masters are converted to new API.

BUG=b:185191942
TEST=builds and ninja test
Comparing flashrom binary before and after the patch,
make clean && make CONFIG_EVERYTHING=yes VERSION=none
binary is the same

Change-Id: I50716686552b4ddcc6089d5afadb19ef59d9f9b4
Signed-off-by: Anastasia Klimchuk <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56101
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
Anastasia Klimchuk
2021-07-06 16:03:11 +10:00
committed by Nico Huber
parent 5a97be363a
commit 0a7f036610
14 changed files with 184 additions and 188 deletions

View File

@ -394,6 +394,25 @@ static int serprog_spi_send_command(const struct flashctx *flash,
return ret;
}
static int serprog_shutdown(void *data)
{
if ((sp_opbuf_usage) || (sp_max_write_n && sp_write_n_bytes))
if (sp_execute_opbuf() != 0)
msg_pwarn("Could not flush command buffer.\n");
if (sp_check_commandavail(S_CMD_S_PIN_STATE)) {
uint8_t dis = 0;
if (sp_docommand(S_CMD_S_PIN_STATE, 1, &dis, 0, NULL) == 0)
msg_pdbg(MSGHEADER "Output drivers disabled\n");
else
msg_pwarn(MSGHEADER "%s: Warning: could not disable output buffers\n", __func__);
}
/* FIXME: fix sockets on windows(?), especially closing */
serialport_shutdown(&sp_fd);
if (sp_max_write_n)
free(sp_write_n_buf);
return 0;
}
static struct spi_master spi_master_serprog = {
.features = SPI_MASTER_4BA,
.max_data_read = MAX_DATA_READ_UNLIMITED,
@ -518,25 +537,6 @@ static const struct par_master par_master_serprog = {
.chip_writen = fallback_chip_writen,
};
static int serprog_shutdown(void *data)
{
if ((sp_opbuf_usage) || (sp_max_write_n && sp_write_n_bytes))
if (sp_execute_opbuf() != 0)
msg_pwarn("Could not flush command buffer.\n");
if (sp_check_commandavail(S_CMD_S_PIN_STATE)) {
uint8_t dis = 0;
if (sp_docommand(S_CMD_S_PIN_STATE, 1, &dis, 0, NULL) == 0)
msg_pdbg(MSGHEADER "Output drivers disabled\n");
else
msg_pwarn(MSGHEADER "%s: Warning: could not disable output buffers\n", __func__);
}
/* FIXME: fix sockets on windows(?), especially closing */
serialport_shutdown(&sp_fd);
if (sp_max_write_n)
free(sp_write_n_buf);
return 0;
}
static enum chipbustype serprog_buses_supported = BUS_NONE;
static int serprog_init(void)