tree/: Drop const from opaque data ptr in master definitions [alt]

The opaque data pointer need not necessarily have constant
data for the life-time of the specific master. This is because
the data field purpose is for the master to use as it sees fit
for managing its own internal state and therefore we should not
constrain this as being RO data at init time.

flashrom-stable:
Add cast in bitbang_spi to avoid compiler warning.

Change-Id: I686c3c79547e35d48f3fd0b524fc98c176dcea6e
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Original-Reviewed-on: https://review.coreboot.org/c/flashrom/+/49131
Original-Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom-stable/+/71336
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
diff --git a/bitbang_spi.c b/bitbang_spi.c
index ac50e67..6d14961 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -101,7 +101,8 @@
 		return ERROR_FLASHROM_BUG;
 	}
 
-	mst.data = master;
+	/* Cast away `const`, but local code must ensure it's still treated as such. */
+	mst.data = (struct bitbang_spi_master *)master;
 	register_spi_master(&mst);
 
 	/* Only mess with the bus if we're sure nobody else uses it. */
diff --git a/programmer.h b/programmer.h
index f1915df..1955094 100644
--- a/programmer.h
+++ b/programmer.h
@@ -608,7 +608,7 @@
 	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);
-	const void *data;
+	void *data;
 };
 
 int default_spi_send_command(const struct flashctx *flash, unsigned int writecnt, unsigned int readcnt,
@@ -690,7 +690,7 @@
 	int (*read) (struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
 	int (*write) (struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
 	int (*erase) (struct flashctx *flash, unsigned int blockaddr, unsigned int blocklen);
-	const void *data;
+	void *data;
 };
 int register_opaque_master(const struct opaque_master *mst);
 
@@ -714,7 +714,7 @@
 	uint16_t (*chip_readw) (const struct flashctx *flash, const chipaddr addr);
 	uint32_t (*chip_readl) (const struct flashctx *flash, const chipaddr addr);
 	void (*chip_readn) (const struct flashctx *flash, uint8_t *buf, const chipaddr addr, size_t len);
-	const void *data;
+	void *data;
 };
 int register_par_master(const struct par_master *mst, const enum chipbustype buses);
 struct registered_master {