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/linux_mtd.c b/linux_mtd.c
index d4c0600..f7da06e 100644
--- a/linux_mtd.c
+++ b/linux_mtd.c
@@ -178,11 +178,11 @@
struct linux_mtd_data *data = flash->mst.opaque->data;
if (data->no_erase)
- flash->chip->feature_bits |= FEATURE_NO_ERASE;
- flash->chip->tested = TEST_OK_PREW;
- flash->chip->total_size = data->total_size / 1024; /* bytes -> kB */
- flash->chip->block_erasers[0].eraseblocks[0].size = data->erasesize;
- flash->chip->block_erasers[0].eraseblocks[0].count =
+ flash->chip.feature_bits |= FEATURE_NO_ERASE;
+ flash->chip.tested = TEST_OK_PREW;
+ flash->chip.total_size = data->total_size / 1024; /* bytes -> kB */
+ flash->chip.block_erasers[0].eraseblocks[0].size = data->erasesize;
+ flash->chip.block_erasers[0].eraseblocks[0].count =
data->total_size / data->erasesize;
return 1;
}
@@ -191,7 +191,7 @@
unsigned int start, unsigned int len)
{
struct linux_mtd_data *data = flash->mst.opaque->data;
- unsigned int eb_size = flash->chip->block_erasers[0].eraseblocks[0].size;
+ unsigned int eb_size = flash->chip.block_erasers[0].eraseblocks[0].size;
unsigned int i;
if (fseek(data->dev_fp, start, SEEK_SET) != 0) {
@@ -226,7 +226,7 @@
unsigned int start, unsigned int len)
{
struct linux_mtd_data *data = flash->mst.opaque->data;
- unsigned int chunksize = flash->chip->block_erasers[0].eraseblocks[0].size;
+ unsigned int chunksize = flash->chip.block_erasers[0].eraseblocks[0].size;
unsigned int i;
if (!data->device_is_writeable)