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/dediprog.c b/dediprog.c
index d8a452f..f03af7e 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -435,7 +435,7 @@
if (cmd_len < 0)
return -1;
- if (flash->chip->feature_bits & FEATURE_4BA_EAR_ANY) {
+ if (flash->chip.feature_bits & FEATURE_4BA_EAR_ANY) {
if (spi_set_extended_address(flash, start >> 24))
return -1;
} else if (start >> 24) {
@@ -480,7 +480,7 @@
return -1;
if (dp_spi_cmd == WRITE_MODE_PAGE_PGM
- && (flash->chip->feature_bits & FEATURE_4BA_WRITE)) {
+ && (flash->chip.feature_bits & FEATURE_4BA_WRITE)) {
cmd_buf[3] = WRITE_MODE_4B_ADDR_256B_PAGE_PGM_0x12;
cmd_buf[4] = JEDEC_BYTE_PROGRAM_4BA;
}
@@ -525,7 +525,7 @@
return -1;
if (dp_spi_cmd == WRITE_MODE_PAGE_PGM) {
- if (flash->chip->feature_bits & FEATURE_4BA_WRITE) {
+ if (flash->chip.feature_bits & FEATURE_4BA_WRITE) {
cmd_buf[3] = WRITE_MODE_4B_ADDR_256B_PAGE_PGM;
cmd_buf[4] = JEDEC_BYTE_PROGRAM_4BA;
} else if (flash->in_4ba_mode) {
@@ -767,7 +767,7 @@
unsigned int start, unsigned int len, uint8_t dedi_spi_cmd)
{
int ret;
- const unsigned int chunksize = flash->chip->page_size;
+ const unsigned int chunksize = flash->chip.page_size;
unsigned int residue = start % chunksize ? chunksize - start % chunksize : 0;
unsigned int bulklen;
const struct dediprog_data *dp_data = flash->mst.spi->data;
@@ -820,7 +820,7 @@
{
/* We can write only up to 65535 pages at once: */
while (len) {
- const size_t len_here = MIN(len, flash->chip->page_size * MAX_BLOCK_COUNT);
+ const size_t len_here = MIN(len, flash->chip.page_size * MAX_BLOCK_COUNT);
const int ret = dediprog_spi_write(flash, buf, start, len_here, dedi_spi_cmd);
if (ret)
return ret;