summaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorNico Huber <nico.huber@secunet.com>2016-05-03 10:48:02 +0200
committerNico Huber <nico.h@gmx.de>2017-06-22 10:34:51 +0000
commit2d62572d1dd0c37eb626fd8faa17b26690f20b15 (patch)
treec76d5035e6fe7b8f9ca841c7030a7f44712f3d16 /flashrom.c
parent8d494992176abe0877c88f06fdbc9c8d8826ae87 (diff)
downloadflashrom-2d62572d1dd0c37eb626fd8faa17b26690f20b15.tar.gz
flashrom-2d62572d1dd0c37eb626fd8faa17b26690f20b15.tar.bz2
flashrom-2d62572d1dd0c37eb626fd8faa17b26690f20b15.zip
Fix linking with libpayload
o Move flashbuses_to_text() to flashrom.c, it's not a cli function. o Guard `!defined(HAVE_STRNLEN)`. This guard was introduced in 23e10b87 (Add a bunch of new/tested stuff and various small changes 24) to support older BSDs. It's probably completely broken because HAVE_STRNLEN is presumably a GNU autotools thing. But we can't fix it without retesting these older BSDs. Change-Id: I561135209b819361d125eeaeef9ff886d6bae987 Signed-off-by: Nico Huber <nico.huber@secunet.com> Reviewed-on: https://review.coreboot.org/18738 Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Reviewed-by: David Hendricks <david.hendricks@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/flashrom.c b/flashrom.c
index 838dfd059..379f75e47 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1163,6 +1163,39 @@ int map_flash(struct flashctx *flash)
return 0;
}
+/*
+ * Return a string corresponding to the bustype parameter.
+ * Memory is obtained with malloc() and must be freed with free() by the caller.
+ */
+char *flashbuses_to_text(enum chipbustype bustype)
+{
+ char *ret = calloc(1, 1);
+ /*
+ * FIXME: Once all chipsets and flash chips have been updated, NONSPI
+ * will cease to exist and should be eliminated here as well.
+ */
+ if (bustype == BUS_NONSPI) {
+ ret = strcat_realloc(ret, "Non-SPI, ");
+ } else {
+ if (bustype & BUS_PARALLEL)
+ ret = strcat_realloc(ret, "Parallel, ");
+ if (bustype & BUS_LPC)
+ ret = strcat_realloc(ret, "LPC, ");
+ if (bustype & BUS_FWH)
+ ret = strcat_realloc(ret, "FWH, ");
+ if (bustype & BUS_SPI)
+ ret = strcat_realloc(ret, "SPI, ");
+ if (bustype & BUS_PROG)
+ ret = strcat_realloc(ret, "Programmer-specific, ");
+ if (bustype == BUS_NONE)
+ ret = strcat_realloc(ret, "None, ");
+ }
+ /* Kill last comma. */
+ ret[strlen(ret) - 2] = '\0';
+ ret = realloc(ret, strlen(ret) + 1);
+ return ret;
+}
+
int probe_flash(struct registered_master *mst, int startchip, struct flashctx *flash, int force)
{
const struct flashchip *chip;