1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 22:21:16 +02:00

programmer: Make use of new register_spi_master() API

Pass pointers to dynamically allocated data to register_spi_master().
This way we can avoid some mutable globals.

Change-Id: Id7821f1db3284b7b5b3d0abfd878b979c53870a1
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/54067
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Nico Huber
2021-05-11 17:53:34 +02:00
parent 7e4968525d
commit 90739d147f
11 changed files with 22 additions and 35 deletions

View File

@ -168,7 +168,7 @@ static int usbblaster_shutdown(void *data)
return 0;
}
static struct spi_master spi_master_usbblaster = {
static const struct spi_master spi_master_usbblaster = {
.max_data_read = 256,
.max_data_write = 256,
.command = usbblaster_spi_send_command,
@ -226,13 +226,12 @@ int usbblaster_spi_init(void)
return -1;
}
usbblaster_data->ftdic = ftdic;
spi_master_usbblaster.data = usbblaster_data;
if (register_shutdown(usbblaster_shutdown, usbblaster_data)) {
free(usbblaster_data);
return -1;
}
register_spi_master(&spi_master_usbblaster, NULL);
register_spi_master(&spi_master_usbblaster, usbblaster_data);
return 0;
}