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.
flashrom-stable: Updated `dirtyjtag_spi` and `dediprog`
that were added/refactored earlier.
Change-Id: Id7821f1db3284b7b5b3d0abfd878b979c53870a1
Signed-off-by: Nico Huber <nico.h@gmx.de>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/54067
Original-Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/72200
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
diff --git a/linux_spi.c b/linux_spi.c
index 697a8a2..ea43f9d 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -61,7 +61,7 @@
static int linux_spi_write_256(struct flashctx *flash, const uint8_t *buf,
unsigned int start, unsigned int len);
-static struct spi_master spi_master_linux = {
+static const struct spi_master spi_master_linux = {
.features = SPI_MASTER_4BA,
.max_data_read = MAX_DATA_UNSPECIFIED, /* TODO? */
.max_data_write = MAX_DATA_UNSPECIFIED, /* TODO? */
@@ -186,13 +186,12 @@
}
spi_data->fd = fd;
spi_data->max_kernel_buf_size = max_kernel_buf_size;
- spi_master_linux.data = spi_data;
if (register_shutdown(linux_spi_shutdown, spi_data)) {
free(spi_data);
goto init_err;
}
- register_spi_master(&spi_master_linux, NULL);
+ register_spi_master(&spi_master_linux, spi_data);
return 0;
init_err: