Draw struct flashchip into struct flashprog_flashctx
We used to have a reference to a dynamically allocated struct flashchip
inside the flash context. But now that we only ever allocate both in one
go, we can let go of the reference and make it a single structure.
Change-Id: I857acb1def6d133a5cbc28fc7a99b7b1a22b55e0
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.sourcearcade.org/c/flashprog/+/494
diff --git a/spi25.c b/spi25.c
index e5a9ddb..75177f8 100644
--- a/spi25.c
+++ b/spi25.c
@@ -317,9 +317,9 @@
static int spi_write_extended_address_register(struct flashctx *const flash, const uint8_t regdata)
{
uint8_t op;
- if (flash->chip->feature_bits & FEATURE_4BA_EAR_C5C8) {
+ if (flash->chip.feature_bits & FEATURE_4BA_EAR_C5C8) {
op = JEDEC_WRITE_EXT_ADDR_REG;
- } else if (flash->chip->feature_bits & FEATURE_4BA_EAR_1716) {
+ } else if (flash->chip.feature_bits & FEATURE_4BA_EAR_1716) {
op = ALT_WRITE_EXT_ADDR_REG_17;
} else {
msg_cerr("Flash misses feature flag for extended-address register.\n");
@@ -359,7 +359,7 @@
static size_t spi_address_length(struct flashctx *const flash, const bool native_4ba)
{
- if (flash->chip->spi_cmd_set == SPI25_EEPROM) {
+ if (flash->chip.spi_cmd_set == SPI25_EEPROM) {
if (flashprog_flash_getsize(flash) > 64*KiB)
return 3;
if (flashprog_flash_getsize(flash) > 256)
@@ -394,7 +394,7 @@
cmd_buf[4] = (addr >> 0) & 0xff;
return len;
case 3:
- if (flash->chip->feature_bits & FEATURE_4BA_EAR_ANY) {
+ if (flash->chip.feature_bits & FEATURE_4BA_EAR_ANY) {
if (spi_set_extended_address(flash, rel_addr >> 24))
return -1;
} else if (rel_addr >> 24) {
@@ -655,7 +655,7 @@
static int spi_nbyte_program(struct flashctx *flash, unsigned int addr, const uint8_t *bytes, unsigned int len)
{
- const bool native_4ba = flash->chip->feature_bits & FEATURE_4BA_WRITE && spi_master_4ba(flash);
+ const bool native_4ba = flash->chip.feature_bits & FEATURE_4BA_WRITE && spi_master_4ba(flash);
const uint8_t op = native_4ba ? JEDEC_BYTE_PROGRAM_4BA : JEDEC_BYTE_PROGRAM;
return spi_write_cmd(flash, op, native_4ba, addr, bytes, len, 10);
}
@@ -668,7 +668,7 @@
if (flash->spi_fast_read)
return flash->spi_fast_read;
- if (flash->chip->feature_bits & FEATURE_4BA_READ && spi_master_4ba(flash))
+ if (flash->chip.feature_bits & FEATURE_4BA_READ && spi_master_4ba(flash))
return &sio_read_4ba;
return &sio_read;
@@ -717,7 +717,7 @@
* spi_chip_write_256 have page_size set to max_writechunk_size, so
* we're OK for now.
*/
- unsigned int page_size = flash->chip->page_size;
+ unsigned int page_size = flash->chip.page_size;
/* Warning: This loop has a very unusual condition and body.
* The loop needs to go through each page with at least one affected