[flashrom] [PATCH] Introduce a compile time option to select a default programmer.

Stefan Tauner stefan.tauner at student.tuwien.ac.at
Tue Sep 25 01:19:47 CEST 2012


Heavily influenced by a discussion with (and based on code from) Peter Stuge.
---
Peter Stuge argued all evening with me that the mandatory -p parameter
is a regression and should be fixed, because the common case is -p internal
and that was the default programmer for most of the installations especially
those users that dont know what they are doing. While i don't think that the
internal programmer should be the new default default (sic) programmer
i do see the point in having a default programmer and don't think that the
"some user used to one default programmer could easily break $stuff when
using another build" outweighs the freedom of maintainers to shoot their
users in the foot especially if they are the same person. ;)

We can not force any distributor to have no default programmer anyway, a
patch that adds one is trivial. Having this build time option does not
neccessarily make us endorsing this option either: If we deem it worth it,
we could add a build warning and add a note in the Makefile/README to
make maintainers consider our arguments.

Signed-off-by: Stefan Tauner <stefan.tauner at student.tuwien.ac.at>
---
 Makefile      |    3 +++
 cli_classic.c |   16 +++++++++++-----
 2 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 9309ce5..dc435b7 100644
--- a/Makefile
+++ b/Makefile
@@ -39,6 +39,7 @@ CFLAGS  ?= -Os -Wall -Wshadow
 EXPORTDIR ?= .
 AR      ?= ar
 RANLIB  ?= ranlib
+CONFIG_DEFAULT_PROGRAMMER ?= PROGRAMMER_INVALID
 
 # If your compiler spits out excessive warnings, run make WARNERROR=no
 # You shouldn't have to change this flag.
@@ -399,6 +400,8 @@ endif
 ###############################################################################
 # Programmer drivers and programmer support infrastructure.
 
+FEATURE_CFLAGS += -D'CONFIG_DEFAULT_PROGRAMMER=$(CONFIG_DEFAULT_PROGRAMMER)'
+
 ifeq ($(CONFIG_INTERNAL), yes)
 FEATURE_CFLAGS += -D'CONFIG_INTERNAL=1'
 PROGRAMMER_OBJS += processor_enable.o chipset_enable.o board_enable.o cbtable.o dmi.o internal.o
diff --git a/cli_classic.c b/cli_classic.c
index 58696ad..4ae375c 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -402,11 +402,17 @@ int main(int argc, char *argv[])
 	}
 
 	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;
+		if (CONFIG_DEFAULT_PROGRAMMER != PROGRAMMER_INVALID) {
+			prog = CONFIG_DEFAULT_PROGRAMMER;
+			msg_pinfo("Using default programmer \"%s\".\n",
+				  programmer_table[CONFIG_DEFAULT_PROGRAMMER].name);
+		} else {
+			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. */
-- 
Kind regards, Stefan Tauner





More information about the flashrom mailing list