Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/35591 )
Change subject: cli_classic: Add convenient '--flash-name' cli opt ......................................................................
cli_classic: Add convenient '--flash-name' 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: I23d574a2f8eaf809a5c0524490db9e3a560ede56 Signed-off-by: Edward O'Callaghan quasisec@chromium.org --- M cli_classic.c 1 file changed, 19 insertions(+), 1 deletion(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/91/35591/1
diff --git a/cli_classic.c b/cli_classic.c index b4112fd..4604043 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -101,6 +101,7 @@ #if CONFIG_PRINT_WIKI == 1 int list_supported_wiki = 0; #endif + int flash_name = 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; @@ -110,6 +111,7 @@ OPTION_FMAP, OPTION_FMAP_FILE, OPTION_FLASH_CONTENTS, + OPTION_FLASH_NAME, }; int ret = 0;
@@ -130,6 +132,7 @@ {"fmap-file", 1, NULL, OPTION_FMAP_FILE}, {"image", 1, NULL, 'i'}, {"flash-contents", 1, NULL, OPTION_FLASH_CONTENTS}, + {"flash-name", 0, NULL, OPTION_FLASH_NAME}, {"list-supported", 0, NULL, 'L'}, {"list-supported-wiki", 0, NULL, 'z'}, {"programmer", 1, NULL, 'p'}, @@ -296,6 +299,9 @@ case OPTION_FLASH_CONTENTS: referencefile = strdup(optarg); break; + case OPTION_FLASH_NAME: + flash_name = 1; + break; case 'L': if (++operation_specified > 1) { fprintf(stderr, "More than one operation " @@ -602,11 +608,23 @@ goto out_shutdown; }
- if (!(read_it | write_it | verify_it | erase_it)) { + if (!(read_it | write_it | verify_it | erase_it | flash_name)) { msg_ginfo("No operations were specified.\n"); goto out_shutdown; }
+ if (flash_name) { + if (fill_flash->chip->vendor && fill_flash->chip->name) { + msg_ginfo("vendor"%s" name="%s"\n", + fill_flash->chip->vendor, + fill_flash->chip->name); + goto out_shutdown; + } else { + ret = -1; + goto out_shutdown; + } + } + if (layoutfile) { layout = get_global_layout(); } else if (ifd && (flashrom_layout_read_from_ifd(&layout, fill_flash, NULL, 0) ||