summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-06-01 02:13:23 +0000
committerStefan Tauner <stefan.tauner@alumni.tuwien.ac.at>2014-06-01 02:13:23 +0000
commit627b2cd59d2b36162ba31ff49dceaa97d9963221 (patch)
treee7b240af0ef343511b247d5689f848d106b09c8d
parentdac049b5de99d62b82aaceba0a97947c67ff2b54 (diff)
downloadflashrom-627b2cd59d2b36162ba31ff49dceaa97d9963221.zip
flashrom-627b2cd59d2b36162ba31ff49dceaa97d9963221.tar.gz
print.c: improve device printing
Add headers and columns (i.e. print device entries in a table-like manner). Also, add and use test_state_to_text() to support the new test states. Corresponding to flashrom svn r1807. Signed-off-by: Stefan Tauner <stefan.tauner@alumni.tuwien.ac.at> Acked-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
-rw-r--r--print.c47
1 files changed, 43 insertions, 4 deletions
diff --git a/print.c b/print.c
index 8ca99d5..9aef8d8 100644
--- a/print.c
+++ b/print.c
@@ -47,6 +47,18 @@ static char* strtok_r(char *str, const char *delim, char **nextp)
}
#endif
+static const char *test_state_to_text(enum test_state test_state)
+{
+ switch (test_state) {
+ case OK: return "OK";
+ case BAD: return "Not working";
+ case NA: return "N/A";
+ case DEP: return "Config-dependent";
+ case NT:
+ default: return "Untested";
+ }
+}
+
/*
* Return a string corresponding to the bustype parameter.
* Memory is obtained with malloc() and must be freed with free() by the caller.
@@ -469,13 +481,40 @@ static void print_supported_boards_helper(const struct board_info *boards,
void print_supported_devs(const struct programmer_entry prog, const char *const type)
{
- int i;
-
const struct dev_entry *const devs = prog.devs.dev;
msg_ginfo("\nSupported %s devices for the %s programmer:\n", type, prog.name);
+ unsigned int maxvendorlen = strlen("Vendor") + 1;
+ unsigned int maxdevlen = strlen("Device") + 1;
+
+ unsigned int i;
for (i = 0; devs[i].vendor_name != NULL; i++) {
- msg_pinfo("%s %s [%04x:%04x]%s\n", devs[i].vendor_name, devs[i].device_name, devs[i].vendor_id,
- devs[i].device_id, (devs[i].status == NT) ? " (untested)" : "");
+ maxvendorlen = max(maxvendorlen, strlen(devs[i].vendor_name));
+ maxdevlen = max(maxdevlen, strlen(devs[i].device_name));
+ }
+ maxvendorlen++;
+ maxdevlen++;
+
+ msg_ginfo("Vendor");
+ for (i = strlen("Vendor"); i < maxvendorlen; i++)
+ msg_ginfo(" ");
+
+ msg_ginfo("Device");
+ for (i = strlen("Device"); i < maxdevlen; i++)
+ msg_ginfo(" ");
+
+ msg_ginfo(" %s IDs Status\n", type);
+
+ for (i = 0; devs[i].vendor_name != NULL; i++) {
+ msg_ginfo("%s", devs[i].vendor_name);
+ unsigned int j;
+ for (j = strlen(devs[i].vendor_name); j < maxvendorlen; j++)
+ msg_ginfo(" ");
+ msg_ginfo("%s", devs[i].device_name);
+ for (j = strlen(devs[i].device_name); j < maxdevlen; j++)
+ msg_ginfo(" ");
+
+ msg_pinfo(" %04x:%04x %s\n", devs[i].vendor_id, devs[i].device_id,
+ test_state_to_text(devs[i].status));
}
}
OpenPOWER on IntegriCloud