Edward O'Callaghan has uploaded this change for review.

View Change

cli_classic: Add convenient '--get-size' cli opt

We have this in the ChromiumOS fork of flashrom which we rely
on to obtain the current flash chip in use. This ports it for
upstream consumption.

Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6
Signed-off-by: Edward O'Callaghan <quasisec@chromium.org>
---
M cli_classic.c
1 file changed, 12 insertions(+), 2 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/92/35592/1
diff --git a/cli_classic.c b/cli_classic.c
index 4604043..52cea52 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -101,7 +101,7 @@
#if CONFIG_PRINT_WIKI == 1
int list_supported_wiki = 0;
#endif
- int flash_name = 0;
+ int flash_name = 0, get_size = 0;
int read_it = 0, write_it = 0, erase_it = 0, verify_it = 0;
int dont_verify_it = 0, dont_verify_all = 0, list_supported = 0, operation_specified = 0;
struct flashrom_layout *layout = NULL;
@@ -112,6 +112,7 @@
OPTION_FMAP_FILE,
OPTION_FLASH_CONTENTS,
OPTION_FLASH_NAME,
+ OPTION_GET_SIZE,
};
int ret = 0;

@@ -133,6 +134,7 @@
{"image", 1, NULL, 'i'},
{"flash-contents", 1, NULL, OPTION_FLASH_CONTENTS},
{"flash-name", 0, NULL, OPTION_FLASH_NAME},
+ {"get-size", 0, NULL, OPTION_GET_SIZE},
{"list-supported", 0, NULL, 'L'},
{"list-supported-wiki", 0, NULL, 'z'},
{"programmer", 1, NULL, 'p'},
@@ -302,6 +304,9 @@
case OPTION_FLASH_NAME:
flash_name = 1;
break;
+ case OPTION_GET_SIZE:
+ get_size = 1;
+ break;
case 'L':
if (++operation_specified > 1) {
fprintf(stderr, "More than one operation "
@@ -608,7 +613,7 @@
goto out_shutdown;
}

- if (!(read_it | write_it | verify_it | erase_it | flash_name)) {
+ if (!(read_it | write_it | verify_it | erase_it | flash_name | get_size)) {
msg_ginfo("No operations were specified.\n");
goto out_shutdown;
}
@@ -625,6 +630,11 @@
}
}

+ if (get_size) {
+ msg_ginfo("%d\n", fill_flash->chip->total_size * 1024);
+ goto out_shutdown;
+ }
+
if (layoutfile) {
layout = get_global_layout();
} else if (ifd && (flashrom_layout_read_from_ifd(&layout, fill_flash, NULL, 0) ||

To view, visit change 35592. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I8f002f3b2012aec4d26b0e81456697b9a5de28d6
Gerrit-Change-Number: 35592
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange