summaryrefslogtreecommitdiffstats
path: root/cli_classic.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2022-02-03 14:39:29 +1100
committerEdward O'Callaghan <quasisec@chromium.org>2022-02-22 05:26:58 +0000
commit83c5c50f91806df599fa9eebb654832879381772 (patch)
tree16a15d446bee739882ee808f44b53b9d8803ae93 /cli_classic.c
parent8f39fd60549b4c20be3c47b9cb7095d96f70c53b (diff)
downloadflashrom-83c5c50f91806df599fa9eebb654832879381772.tar.gz
flashrom-83c5c50f91806df599fa9eebb654832879381772.tar.bz2
flashrom-83c5c50f91806df599fa9eebb654832879381772.zip
cli_classic: Use flashrom_flash_getsize() over raw access
Use native libflashrom entry-points for getting flash size over accessing internal struct members within cli code. BUG=none TEST=`sudo ./flashrom -p internal --get-size`. Change-Id: Iff70a0de1dee517c4e38c45b1540c42326a13340 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/61583 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Angel Pons <th3fanbus@gmail.com>
Diffstat (limited to 'cli_classic.c')
-rw-r--r--cli_classic.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/cli_classic.c b/cli_classic.c
index 8c337eb22..3391af5b0 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -158,7 +158,7 @@ static int do_read(struct flashctx *const flash, const char *const filename)
{
int ret;
- unsigned long size = flash->chip->total_size * 1024;
+ unsigned long size = flashrom_flash_getsize(flash);
unsigned char *buf = calloc(size, sizeof(unsigned char));
if (!buf) {
msg_gerr("Memory allocation failed!\n");
@@ -189,7 +189,7 @@ static int do_extract(struct flashctx *const flash)
static int do_write(struct flashctx *const flash, const char *const filename, const char *const referencefile)
{
- const size_t flash_size = flash->chip->total_size * 1024;
+ const size_t flash_size = flashrom_flash_getsize(flash);
int ret = 1;
uint8_t *const newcontents = malloc(flash_size);
@@ -225,7 +225,7 @@ _free_ret:
static int do_verify(struct flashctx *const flash, const char *const filename)
{
- const size_t flash_size = flash->chip->total_size * 1024;
+ const size_t flash_size = flashrom_flash_getsize(flash);
int ret = 1;
uint8_t *const newcontents = malloc(flash_size);
@@ -809,7 +809,7 @@ int main(int argc, char *argv[])
}
if (flash_size) {
- printf("%d\n", fill_flash->chip->total_size * 1024);
+ printf("%ld\n", flashrom_flash_getsize(fill_flash));
goto out_shutdown;
}
@@ -846,7 +846,7 @@ int main(int argc, char *argv[])
}
free(fmapfile_buffer);
} else if (fmap && (flashrom_layout_read_fmap_from_rom(&layout, fill_flash, 0,
- fill_flash->chip->total_size * 1024) || process_include_args(layout, include_args))) {
+ flashrom_flash_getsize(fill_flash)) || process_include_args(layout, include_args))) {
ret = 1;
goto out_shutdown;
}