Stefan Reinauer has uploaded this change for review. ( https://review.coreboot.org/c/em100/+/37125 )
Change subject: Refactor chips configuration ......................................................................
Refactor chips configuration
- Doesn't need to happen before USB device detection. In fact, available chips might depend on hardware version.
- Move to separate function
Change-Id: I22aefc2c2d415dc47e6a0eae42349b280543df15 Signed-off-by: Stefan Reinauer stefan.reinauer@coreboot.org --- M em100.c 1 file changed, 31 insertions(+), 22 deletions(-)
git pull ssh://review.coreboot.org:29418/em100 refs/changes/25/37125/1
diff --git a/em100.c b/em100.c index d682991..b8d5969 100644 --- a/em100.c +++ b/em100.c @@ -680,6 +680,33 @@ return strdup(file); }
+static chipdesc *setup_chips(const char *desiredchip) +{ + const chipdesc *chip = chips; + if (desiredchip) { + do { + if (strcasecmp(desiredchip, chip->name) == 0) { + printf("will emulate '%s'\n", chip->name); + break; + } + } while ((++chip)->name); + + if (chip->name == NULL) { + printf("Supported chips:\n"); + chip = chips; + do { + printf("%s ", chip->name); + } while ((++chip)->name); + printf("\n\nCould not find emulation for '%s'.\n", + desiredchip); + + return NULL; + } + + } + return chip; +} + static const struct option longopts[] = { {"set", 1, 0, 'c'}, {"download", 1, 0, 'd'}, @@ -832,33 +859,15 @@ } }
- const chipdesc *chip = chips; - if (desiredchip) { - do { - if (strcasecmp(desiredchip, chip->name) == 0) { - printf("will emulate '%s'\n", chip->name); - break; - } - } while ((++chip)->name); - - if (chip->name == NULL) { - printf("Supported chips:\n"); - chip = chips; - do { - printf("%s ", chip->name); - } while ((++chip)->name); - printf("\n\nCould not find emulation for '%s'.\n", - desiredchip); - - return 1; - } - } - struct em100 em100; if (!em100_attach(&em100, bus, device, serial_number)) { return 1; }
+ const chipdesc *chip = setup_chips(desiredchip); + if (!chip) + return 1; + printf("MCU version: %d.%02d\n", em100.mcu >> 8, em100.mcu & 0xff); if (em100.fpga > 0x0033) { /* 0.51 */ if (em100.hwversion == HWVERSION_EM100PRO)