From 6271d370afd2103ec5d2f70bd1315cbf0513a1cd Mon Sep 17 00:00:00 2001 From: Bernhard Nortmann Date: Wed, 25 May 2016 00:36:11 +0200 Subject: [PATCH] fexc: Fix thinko in script decompiler Both the error output in function decompile_section() and the definition of GPIO_BANK_MAX in script.h suffered from an "off by one" logic. The bank numbering in the .bin is based on 1, so it should be added to ('A' - 1) for human-readable output, and the maximum number corresponding to 'N' is 14. This became apparent when trying to translate a fex2bin-compiled a80_optimus_board.bin back to its original .fex equivalent. Signed-off-by: Bernhard Nortmann --- script.h | 2 +- script_bin.c | 9 ++++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/script.h b/script.h index b4c2aad..7df3151 100644 --- a/script.h +++ b/script.h @@ -19,7 +19,7 @@ #include "list.h" -#define GPIO_BANK_MAX 13 /* N */ +#define GPIO_BANK_MAX 14 /* N, (zero-based) index 13 */ /** head of the data tree */ struct script { diff --git a/script_bin.c b/script_bin.c index ffe9051..6a06684 100644 --- a/script_bin.c +++ b/script_bin.c @@ -269,9 +269,12 @@ static int decompile_section(void *bin, size_t bin_size, } else if (gpio->port == 0xffff) { ; /* port:power */ } else if (gpio->port < 1 || gpio->port > GPIO_BANK_MAX) { - pr_err("%s: %s.%s: unknown GPIO port bank %c (%u)\n", - filename, section->name, entry->name, - 'A'+gpio->port, gpio->port); + pr_err("%s: %s.%s: unknown GPIO port bank ", + filename, section->name, entry->name); + char c = 'A' + gpio->port - 1; + if (c >= 'A' && c <= 'Z') + pr_err("%c ", c); + pr_err("(%u)\n", gpio->port); goto failure; } v[0] = gpio->mul_sel;