Edward O'Callaghan has uploaded this change for review.

View Change

cli_classic.c: Factor out rom bus limits exceeded validation

Cave out relevant logic relating to validating the rom decode
limits fit within the common buses with certain flash-programmer
pairingings into it's own function.

Move the comment to the top of the new symbol while we are here
and rewrite the grammar to be a bit more understandable.

Change-Id: Iba1c3c8ab2edc094ede59156ae5e846900fc0777
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M cli_classic.c
1 file changed, 43 insertions(+), 12 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/61/68661/1
diff --git a/cli_classic.c b/cli_classic.c
index 4d327f4..19551b5 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -560,6 +560,31 @@
return limitexceeded;
}

+/**
+ * Sometimes chip and programmer combinations share more than one bus in common.
+ * If the rom decode limit is exceed on all relevent buses then return true unless
+ * overriden with a force flag, otherwise return false.
+ */
+static bool max_rom_decode_limitexceeded(const struct flashctx *flash, bool force)
+{
+ const unsigned int limitexceeded = count_max_decode_exceedings(fill_flash, &max_rom_decode);
+
+ if (limitexceeded > 0 && !force) {
+ enum chipbustype commonbuses = fill_flash->mst->buses_supported & fill_flash->chip->bustype;
+
+ 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");
+
+ return true;
+ }
+
+ return false;
+}
+
int main(int argc, char *argv[])
{
const struct flashchip *chip = NULL;
@@ -1058,18 +1083,7 @@

print_chip_support_status(fill_flash->chip);

- unsigned int limitexceeded = count_max_decode_exceedings(fill_flash, &max_rom_decode);
- 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");
+ if (max_rom_decode_limitexceeded(fill_flash, force)) {
ret = 1;
goto out_shutdown;
}

To view, visit change 68661. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Iba1c3c8ab2edc094ede59156ae5e846900fc0777
Gerrit-Change-Number: 68661
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange