diff options
author | Anastasia Klimchuk <aklm@chromium.org> | 2021-07-06 16:18:44 +1000 |
---|---|---|
committer | Edward O'Callaghan <quasisec@chromium.org> | 2021-08-25 02:24:23 +0000 |
commit | a69c5196d20d136b1de120f0fa5ea1e06c3776da (patch) | |
tree | d7479140777b3f91c8a49cc7065e1269391b12b9 /sb600spi.c | |
parent | 9db8e12c169aa5a74154d9fb9993af8044afe39f (diff) | |
download | flashrom-git-a69c5196d20d136b1de120f0fa5ea1e06c3776da.tar.gz |
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 <aklm@chromium.org>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/56103
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Diffstat (limited to 'sb600spi.c')
-rw-r--r-- | sb600spi.c | 5 |
1 files changed, 3 insertions, 2 deletions
@@ -589,6 +589,7 @@ static const struct spi_master spi_master_sb600 = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = sb600spi_shutdown, }; static const struct spi_master spi_master_yangtze = { @@ -599,6 +600,7 @@ static const struct spi_master spi_master_yangtze = { .read = default_spi_read, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = sb600spi_shutdown, }; static const struct spi_master spi_master_promontory = { @@ -609,6 +611,7 @@ static const struct spi_master spi_master_promontory = { .read = promontory_read_memmapped, .write_256 = default_spi_write_256, .write_aai = default_spi_write_aai, + .shutdown = sb600spi_shutdown, }; int sb600_probe_spi(struct pci_dev *dev) @@ -786,8 +789,6 @@ int sb600_probe_spi(struct pci_dev *dev) data->flash = NULL; data->spibar = sb600_spibar; - register_shutdown(sb600spi_shutdown, data); - /* 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, data); |