From 23b69d33c33f8e8018303a5bf351ef7203e40217 Mon Sep 17 00:00:00 2001 From: hailfinger Date: Sun, 22 Jul 2012 12:01:43 +0000 Subject: Always require the --programmer parameter on the command line if any flash chip access (probe/read/write/erase/...) is requested. Fix a few man page oddities as well. Signed-off-by: Carl-Daniel Hailfinger Acked-by: Stefan Tauner git-svn-id: https://code.coreboot.org/svn/flashrom/trunk@1552 2b7e53f0-3cfb-0310-b3e9-8179ed1497e1 --- cli_classic.c | 95 +++++++++++------------------------------------------------ 1 file changed, 17 insertions(+), 78 deletions(-) (limited to 'cli_classic.c') diff --git a/cli_classic.c b/cli_classic.c index b415076..cf3874c 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -31,87 +31,20 @@ #include "flashchips.h" #include "programmer.h" -#if CONFIG_INTERNAL == 1 -static enum programmer default_programmer = PROGRAMMER_INTERNAL; -#elif CONFIG_DUMMY == 1 -static enum programmer default_programmer = PROGRAMMER_DUMMY; -#else -/* If neither internal nor dummy are selected, we must pick a sensible default. - * Since there is no reason to prefer a particular external programmer, we fail - * if more than one of them is selected. If only one is selected, it is clear - * that the user wants that one to become the default. - */ -#if CONFIG_NIC3COM+CONFIG_NICREALTEK+CONFIG_NICNATSEMI+CONFIG_GFXNVIDIA+CONFIG_DRKAISER+CONFIG_SATASII+CONFIG_ATAHPT+CONFIG_FT2232_SPI+CONFIG_SERPROG+CONFIG_BUSPIRATE_SPI+CONFIG_DEDIPROG+CONFIG_RAYER_SPI+CONFIG_NICINTEL+CONFIG_NICINTEL_SPI+CONFIG_OGP_SPI+CONFIG_SATAMV > 1 -#error Please enable either CONFIG_DUMMY or CONFIG_INTERNAL or disable support for all programmers except one. -#endif -static enum programmer default_programmer = -#if CONFIG_NIC3COM == 1 - PROGRAMMER_NIC3COM -#endif -#if CONFIG_NICREALTEK == 1 - PROGRAMMER_NICREALTEK -#endif -#if CONFIG_NICNATSEMI == 1 - PROGRAMMER_NICNATSEMI -#endif -#if CONFIG_GFXNVIDIA == 1 - PROGRAMMER_GFXNVIDIA -#endif -#if CONFIG_DRKAISER == 1 - PROGRAMMER_DRKAISER -#endif -#if CONFIG_SATASII == 1 - PROGRAMMER_SATASII -#endif -#if CONFIG_ATAHPT == 1 - PROGRAMMER_ATAHPT -#endif -#if CONFIG_FT2232_SPI == 1 - PROGRAMMER_FT2232_SPI -#endif -#if CONFIG_SERPROG == 1 - PROGRAMMER_SERPROG -#endif -#if CONFIG_BUSPIRATE_SPI == 1 - PROGRAMMER_BUSPIRATE_SPI -#endif -#if CONFIG_DEDIPROG == 1 - PROGRAMMER_DEDIPROG -#endif -#if CONFIG_RAYER_SPI == 1 - PROGRAMMER_RAYER_SPI -#endif -#if CONFIG_NICINTEL == 1 - PROGRAMMER_NICINTEL -#endif -#if CONFIG_NICINTEL_SPI == 1 - PROGRAMMER_NICINTEL_SPI -#endif -#if CONFIG_OGP_SPI == 1 - PROGRAMMER_OGP_SPI -#endif -#if CONFIG_SATAMV == 1 - PROGRAMMER_SATAMV -#endif -#if CONFIG_LINUX_SPI == 1 - PROGRAMMER_LINUX_SPI -#endif -; -#endif - static void cli_classic_usage(const char *name) { - printf("Usage: flashrom [-n] [-V] [-f] [-h|-R|-L|" + printf("Usage: flashrom [-h|-R|-L|" #if CONFIG_PRINT_WIKI == 1 - "-z|" + "-z|" #endif - "-E|-r |-w |-v ]\n" - " [-c ] [-l ] [-o ]\n" - " [-i ] [-p [:]]\n\n"); + "-p [:]\n" + " [-E|-r |-w |-v ] [-c ]\n" + " [-l [-i ]] [-n] [-f]]\n" + " [-V[V[V]]] [-o ]\n\n"); printf("Please note that the command line interface for flashrom has " "changed between\n" - "0.9.1 and 0.9.2 and will change again before flashrom 1.0.\n" + "0.9.5 and 0.9.6 and will change again before flashrom 1.0.\n" "Do not use flashrom in scripts or other automated tools " "without checking\n" "that your flashrom version won't interpret options in a " @@ -360,8 +293,9 @@ int main(int argc, char *argv[]) } } if (prog == PROGRAMMER_INVALID) { - fprintf(stderr, "Error: Unknown programmer " - "%s.\n", optarg); + fprintf(stderr, "Error: Unknown programmer \"%s\". Valid choices are:\n", + optarg); + list_programmers_linebreak(0, 80, 0); cli_classic_abort_usage(); } break; @@ -468,8 +402,13 @@ int main(int argc, char *argv[]) flash = NULL; } - if (prog == PROGRAMMER_INVALID) - prog = default_programmer; + if (prog == PROGRAMMER_INVALID) { + msg_perr("Please select a programmer with the --programmer parameter.\n" + "Valid choices are:\n"); + list_programmers_linebreak(0, 80, 0); + ret = 1; + goto out; + } /* FIXME: Delay calibration should happen in programmer code. */ myusec_calibrate_delay(); -- cgit v1.2.1