--mainboard is a relic from a time before external programmers and makes the CLI inconsistent. Use a programmer parameter instead and free up the short option -m.
A nice side effect is that there is one less corner case we have to care about in the logging patch.
Signed-off-by: Carl-Daniel Hailfinger c-d.hailfinger.devel.2006@gmx.net
Index: flashrom-kill_cli_mainboard_parameter/cli_classic.c =================================================================== --- flashrom-kill_cli_mainboard_parameter/cli_classic.c (Revision 1482) +++ flashrom-kill_cli_mainboard_parameter/cli_classic.c (Arbeitskopie) @@ -128,11 +128,6 @@ " -V | --verbose more verbose output\n" " -c | --chip <chipname> probe only for specified " "flash chip\n" -#if CONFIG_INTERNAL == 1 - /* FIXME: --mainboard should be a programmer parameter */ - " -m | --mainboard <[vendor:]part> override mainboard " - "detection\n" -#endif " -f | --force force specific operations " "(see man page)\n" " -n | --noverify don't auto-verify\n" @@ -190,7 +185,6 @@ {"verify", 1, NULL, 'v'}, {"noverify", 0, NULL, 'n'}, {"chip", 1, NULL, 'c'}, - {"mainboard", 1, NULL, 'm'}, {"verbose", 0, NULL, 'V'}, {"force", 0, NULL, 'f'}, {"layout", 1, NULL, 'l'}, @@ -275,17 +269,6 @@ } erase_it = 1; break; - case 'm': -#if CONFIG_INTERNAL == 1 - tempstr = strdup(optarg); - lb_vendor_dev_from_string(tempstr); -#else - fprintf(stderr, "Error: Internal programmer support " - "was not compiled in and --mainboard only\n" - "applies to the internal programmer. Aborting.\n"); - cli_classic_abort_usage(); -#endif - break; case 'f': force = 1; break; Index: flashrom-kill_cli_mainboard_parameter/internal.c =================================================================== --- flashrom-kill_cli_mainboard_parameter/internal.c (Revision 1482) +++ flashrom-kill_cli_mainboard_parameter/internal.c (Arbeitskopie) @@ -213,6 +213,16 @@ } free(arg);
+ arg = extract_programmer_param("mainboard"); + if (arg && strlen(arg)) { + lb_vendor_dev_from_string(arg); + } else if (arg && !strlen(arg)) { + msg_perr("Missing argument for mainboard.\n"); + free(arg); + return 1; + } + free(arg); + get_io_perms(); if (register_shutdown(internal_shutdown, NULL)) return 1; Index: flashrom-kill_cli_mainboard_parameter/cbtable.c =================================================================== --- flashrom-kill_cli_mainboard_parameter/cbtable.c (Revision 1482) +++ flashrom-kill_cli_mainboard_parameter/cbtable.c (Arbeitskopie) @@ -33,17 +33,19 @@ char *lb_part = NULL, *lb_vendor = NULL; int partvendor_from_cbtable = 0;
-void lb_vendor_dev_from_string(char *boardstring) +void lb_vendor_dev_from_string(const char *boardstring) { + /* strtok may modify the original string. */ + char *tempstr = strdup(boardstring); char *tempstr2 = NULL; - strtok(boardstring, ":"); + strtok(tempstr, ":"); tempstr2 = strtok(NULL, ":"); if (tempstr2) { - lb_vendor = boardstring; + lb_vendor = tempstr; lb_part = tempstr2; } else { lb_vendor = NULL; - lb_part = boardstring; + lb_part = tempstr; } }
Index: flashrom-kill_cli_mainboard_parameter/flashrom.8 =================================================================== --- flashrom-kill_cli_mainboard_parameter/flashrom.8 (Revision 1482) +++ flashrom-kill_cli_mainboard_parameter/flashrom.8 (Arbeitskopie) @@ -88,19 +88,6 @@ without the vendor name as parameter. Please note that the chip name is case sensitive. .TP -.B "-m, --mainboard" [<vendor>:]<board> -Override mainboard settings. -.sp -flashrom reads the coreboot table to determine the current mainboard. If no -coreboot table could be read or if you want to override these values, you can -specify -m, e.g.: -.sp -.B " flashrom --mainboard AGAMI:ARUMA -w agami_aruma.rom" -.sp -See the 'Known boards' or 'Known laptops' section in the output -of 'flashrom -L' for a list of boards which require the specification of -the board name, if no coreboot table is found. -.TP .B "-f, --force" Force one or more of the following actions: .sp @@ -245,11 +232,16 @@ running coreboot, the mainboard type is determined from the coreboot table. Otherwise, the mainboard is detected by examining the onboard PCI devices and possibly DMI info. If PCI and DMI do not contain information to uniquely -identify the mainboard (which is the exception), it might be necessary to -specify the mainboard using the -.B -m -switch (see above). +identify the mainboard (which is the exception), or if you want to override +the detected mainboard model, you can specify the mainboard using the .sp +.B " flashrom -p internal:mainboard=[<vendor>:]<board>" +syntax. +.sp +See the 'Known boards' or 'Known laptops' section in the output +of 'flashrom -L' for a list of boards which require the specification of +the board name, if no coreboot table is found. +.sp Some of these board-specific flash enabling functions (called .BR "board enables" ) in flashrom have not yet been tested. If your mainboard is detected needing Index: flashrom-kill_cli_mainboard_parameter/programmer.h =================================================================== --- flashrom-kill_cli_mainboard_parameter/programmer.h (Revision 1482) +++ flashrom-kill_cli_mainboard_parameter/programmer.h (Arbeitskopie) @@ -264,7 +264,7 @@ void cleanup_cpu_msr(void);
/* cbtable.c */ -void lb_vendor_dev_from_string(char *boardstring); +void lb_vendor_dev_from_string(const char *boardstring); int coreboot_init(void); extern char *lb_part, *lb_vendor; extern int partvendor_from_cbtable;