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/edi.c b/edi.c
index efe41c5..e6a51a1 100644
--- a/edi.c
+++ b/edi.c
@@ -291,7 +291,7 @@
unsigned int timeout = 64;
int rc;
- if (size != flash->chip->page_size) {
+ if (size != flash->chip.page_size) {
msg_perr("%s: Block erase size is not page size!\n", __func__);
return -1;
}
@@ -338,17 +338,17 @@
unsigned int i, j;
int rc;
- if ((start % flash->chip->page_size) != 0) {
+ if ((start % flash->chip.page_size) != 0) {
msg_perr("%s: Start address is not page-aligned!\n", __func__);
return -1;
}
- if ((len % flash->chip->page_size) != 0) {
+ if ((len % flash->chip.page_size) != 0) {
msg_perr("%s: Length is not page-aligned!\n", __func__);
return -1;
}
- pages = len / flash->chip->page_size;
+ pages = len / flash->chip.page_size;
rc = edi_spi_enable(spi);
if (rc < 0) {
@@ -364,7 +364,7 @@
if (rc < 0)
return -1;
- for (j = 0; j < flash->chip->page_size; j++) {
+ for (j = 0; j < flash->chip.page_size; j++) {
rc = edi_spi_address(spi, start, address);
if (rc < 0)
return -1;
@@ -396,7 +396,7 @@
return -1;
}
- flashprog_progress_add(flash, flash->chip->page_size);
+ flashprog_progress_add(flash, flash->chip.page_size);
}
rc = edi_spi_disable(spi);