From 9e3a6984da1bb38af37ce4bb54af8f7475b7c766 Mon Sep 17 00:00:00 2001 From: Stefan Tauner Date: Fri, 15 Aug 2014 17:17:59 +0000 Subject: Refine handling chips that exceed maximum programmer sizes - Change check_max_decode() to return the number of (common) busses where the flash chip exceeds the supported size of the programmer. - Refine its signature to use a flashctx pointer only. - Move CLI-related bits to cli_classic.c. - Rename check_max_decode() to count_max_decode_exceedings() to better reflect what it (now) really does. - Refine the messages printed by the caller to better integrate with the new setup, and simplify them. Corresponding to flashrom svn r1842. Signed-off-by: Stefan Tauner Acked-by: Carl-Daniel Hailfinger --- cli_classic.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'cli_classic.c') diff --git a/cli_classic.c b/cli_classic.c index 73ab57a4..945ad7b7 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -91,7 +91,6 @@ static int check_filename(char *filename, char *type) int main(int argc, char *argv[]) { - unsigned long size; /* Probe for up to three flash chips. */ const struct flashchip *chip = NULL; struct flashctx flashes[6] = {{0}}; @@ -501,9 +500,18 @@ int main(int argc, char *argv[]) print_chip_support_status(fill_flash->chip); - size = fill_flash->chip->total_size * 1024; - if (check_max_decode(fill_flash->mst->buses_supported & fill_flash->chip->bustype, size) && (!force)) { - msg_cerr("Chip is too big for this programmer (-V gives details). Use --force to override.\n"); + unsigned int limitexceeded = count_max_decode_exceedings(fill_flash); + if (limitexceeded > 0 && !force) { + enum chipbustype commonbuses = fill_flash->mst->buses_supported & fill_flash->chip->bustype; + + /* Sometimes chip and programmer have more than one bus in common, + * and the limit is not exceeded on all buses. Tell the user. */ + if ((bitcount(commonbuses) > limitexceeded)) { + msg_pdbg("There is at least one interface available which could support the size of\n" + "the selected flash chip.\n"); + } + msg_cerr("This flash chip is too big for this programmer (--verbose/-V gives details).\n" + "Use --force/-f to override at your own risk.\n"); ret = 1; goto out_shutdown; } -- cgit v1.2.3