mirror of
https://review.coreboot.org/flashrom.git
synced 2025-07-03 06:53:18 +02:00
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>
This commit is contained in:

committed by
Edward O'Callaghan

parent
9db8e12c16
commit
a69c5196d2
10
it85spi.c
10
it85spi.c
@ -289,6 +289,7 @@ static const struct spi_master spi_master_it85xx = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.write_aai = default_spi_write_aai,
|
||||
.shutdown = it85xx_shutdown,
|
||||
};
|
||||
|
||||
int it85xx_spi_init(struct superio s)
|
||||
@ -353,20 +354,13 @@ int it85xx_spi_init(struct superio s)
|
||||
data->ce_high = ((unsigned char *)base) + 0xE00; /* 0xFFFFFE00 */
|
||||
data->ce_low = ((unsigned char *)base) + 0xD00; /* 0xFFFFFD00 */
|
||||
|
||||
if (register_shutdown(it85xx_shutdown, data)) {
|
||||
free(data);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* FIXME: Really leave FWH enabled? We can't use this region
|
||||
* anymore since accessing it would mess up IT85 communication.
|
||||
* If we decide to disable FWH for this region, we should print
|
||||
* a debug message about it.
|
||||
*/
|
||||
/* Set this as SPI controller. */
|
||||
register_spi_master(&spi_master_it85xx, data);
|
||||
|
||||
return 0;
|
||||
return register_spi_master(&spi_master_it85xx, data);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user