summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-08-13 11:38:44 +0000
committerCarl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>2009-08-13 11:38:44 +0000
commit204b076df7c7c9466ada9120780dc8aad2cd6586 (patch)
tree546e73a67f822fa95710ca23db8e1286fdab53dd /flashrom.c
parentb4fe6648d1c73f3de9cff84c5836ae22485194f2 (diff)
downloadast2050-flashrom-204b076df7c7c9466ada9120780dc8aad2cd6586.zip
ast2050-flashrom-204b076df7c7c9466ada9120780dc8aad2cd6586.tar.gz
Generate the usage message by walking the list of available programmers
This makes sure compiled out programmers are not listed. Tested, usage output is identical to the hardcoded variant. Corresponding to flashrom svn r684. Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net> Acked-by: Stefan Reinauer <stepan@coresystems.de>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c35
1 files changed, 32 insertions, 3 deletions
diff --git a/flashrom.c b/flashrom.c
index 7133145..acdb38b 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -488,6 +488,11 @@ int erase_flash(struct flashchip *flash)
void usage(const char *name)
{
+ const char *pname;
+ int pnamelen;
+ int remaining = 0;
+ enum programmer p;
+
printf("usage: %s [-VfLzhR] [-E|-r file|-w file|-v file] [-c chipname]\n"
" [-m [vendor:]part] [-l file] [-i image] [-p programmer]\n\n", name);
@@ -510,9 +515,33 @@ void usage(const char *name)
" -i | --image <name>: only flash image name from flash layout\n"
" -L | --list-supported: print supported devices\n"
" -z | --list-supported-wiki: print supported devices in wiki syntax\n"
- " -p | --programmer <name>: specify the programmer device\n"
- " (internal, dummy, nic3com, satasii,\n"
- " it87spi, ft2232spi, serprog)\n"
+ " -p | --programmer <name>: specify the programmer device");
+
+ for (p = 0; p < PROGRAMMER_INVALID; p++) {
+ pname = programmer_table[p].name;
+ pnamelen = strlen(pname);
+ if (remaining - pnamelen - 2 < 0) {
+ printf("\n ");
+ remaining = 43;
+ } else {
+ printf(" ");
+ remaining--;
+ }
+ if (p == 0) {
+ printf("(");
+ remaining--;
+ }
+ printf("%s", pname);
+ remaining -= pnamelen;
+ if (p < PROGRAMMER_INVALID - 1) {
+ printf(",");
+ remaining--;
+ } else {
+ printf(")\n");
+ }
+ }
+
+ printf(
" -h | --help: print this help text\n"
" -R | --version: print the version (release)\n"
"\nYou can specify one of -E, -r, -w, -v or no operation. If no operation is\n"
OpenPOWER on IntegriCloud