mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-27 15:12:36 +02:00
spi_master: Add shutdown function in spi_master struct
With this, register_spi_master can take care of register_shutdown as well, and every spi master only needs to call register_spi_master instead of calling both register_spi_master and register_shutdown. Testing: In dummyflasher, comment out free(data) in shutdown. Test fails with error: ../dummyflasher.c:949: note: block 0x55e0727a6e40 allocated here ERROR: dummy_init_and_shutdown_test_success leaked 1 block(s) Means, shutdown function is invoked for drivers with "old" API (so, transitioning from old to new API is not breaking anything). Next patches in the chain converts spi masters to use new API. BUG=b:185191942 TEST=builds and ninja test Change-Id: I2dc80dceca2f8204bcd0dad1f51753d7e79f1af5 Signed-off-by: Anastasia Klimchuk <aklm@chromium.org> Reviewed-on: https://review.coreboot.org/c/flashrom/+/55932 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Nico Huber <nico.h@gmx.de>
This commit is contained in:
parent
541f79df44
commit
5a97be363a
@ -356,6 +356,7 @@ struct spi_master {
|
||||
int (*read)(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int (*shutdown)(void *data);
|
||||
void *data;
|
||||
};
|
||||
|
||||
|
7
spi.c
7
spi.c
@ -135,6 +135,13 @@ int register_spi_master(const struct spi_master *mst, void *data)
|
||||
{
|
||||
struct registered_master rmst = {0};
|
||||
|
||||
if (mst->shutdown) {
|
||||
if (register_shutdown(mst->shutdown, data)) {
|
||||
mst->shutdown(data); /* cleanup */
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!mst->write_aai || !mst->write_256 || !mst->read || !mst->command ||
|
||||
!mst->multicommand ||
|
||||
((mst->command == default_spi_send_command) &&
|
||||
|
Loading…
x
Reference in New Issue
Block a user