From a69c5196d20d136b1de120f0fa5ea1e06c3776da Mon Sep 17 00:00:00 2001 From: Anastasia Klimchuk Date: Tue, 6 Jul 2021 16:18:44 +1000 Subject: spi_master: Use new API to register shutdown function This allows spi masters to register shutdown function in spi_master struct, which means there is no need to call register_shutdown in init function, since this call is now a part of register_spi_master. As a consequence of using new API, two things are happening here: 1) No resource leakage anymore in case register_shutdown() would fail, 2) Fixed propagation of register_spi_master() return values. Basic testing: when I comment out free(data) in linux_spi_shutdown, test fails with error ../linux_spi.c:235: note: block 0x55a4db276510 allocated here ERROR: linux_spi_init_and_shutdown_test_success leaked 1 block(s) Means, shutdown function is invoked. BUG=b:185191942 TEST= 1) builds and ninja test including CB:56911 2) On ARMv7 device flashrom -p linux_spi -V -> using linux_spi, chip found 3) On x86_64 AMD device flashrom -p internal -V -> this is actually using sb600spi, chip found Change-Id: Ib60300f9ddb295a255d5ef3f8da0e07064207140 Signed-off-by: Anastasia Klimchuk Reviewed-on: https://review.coreboot.org/c/flashrom/+/56103 Tested-by: build bot (Jenkins) Reviewed-by: Nico Huber Reviewed-by: Angel Pons Reviewed-by: Edward O'Callaghan --- it87spi.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'it87spi.c') diff --git a/it87spi.c b/it87spi.c index e55232858..3e422d7df 100644 --- a/it87spi.c +++ b/it87spi.c @@ -304,6 +304,7 @@ static const struct spi_master spi_master_it87xx = { .read = it8716f_spi_chip_read, .write_256 = it8716f_spi_chip_write_256, .write_aai = spi_chip_write_1, + .shutdown = it8716f_shutdown, }; static uint16_t it87spi_probe(uint16_t port) @@ -419,13 +420,10 @@ static uint16_t it87spi_probe(uint16_t port) data->flashport = flashport; data->fast_spi = 1; - register_shutdown(it8716f_shutdown, data); - 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, data); - return 0; + return register_spi_master(&spi_master_it87xx, data); } int init_superio_ite(void) -- cgit v1.2.3