Kill global variables, constants and functions if local scope suffices

Constify variables where possible.
Initialize programmer-related variables explicitly in programmer_init to
allow running programmer_init from a clean state after
programmer_shutdown.
Prohibit registering programmer shutdown functions before init or after
shutdown.
Kill some dead code.
Rename global variables with namespace-polluting names.
Use a previously unused locking helper function in sst49lfxxxc.c.

This is needed for libflashrom.

Effects on the binary size of flashrom are minimal (300 bytes
shrinkage), but the data section shrinks by 4384 bytes, and that's a
good thing if flashrom is operating in constrained envionments.

Corresponding to flashrom svn r1068.

Signed-off-by: Carl-Daniel Hailfinger <c-d.hailfinger.devel.2006@gmx.net>
Acked-by: Michael Karcher <flashrom@mkarcher.dialup.fu-berlin.de>
diff --git a/cli_classic.c b/cli_classic.c
index 791d836..8279cc2 100644
--- a/cli_classic.c
+++ b/cli_classic.c
@@ -31,7 +31,7 @@
 #include "flash.h"
 #include "flashchips.h"
 
-void cli_classic_usage(const char *name)
+static void cli_classic_usage(const char *name)
 {
 	const char *pname;
 	int pnamelen;
@@ -118,7 +118,7 @@
 	         "flash chips.\n\n");
 }
 
-void cli_classic_abort_usage(void)
+static void cli_classic_abort_usage(void)
 {
 	printf("Please run \"flashrom --help\" for usage info.\n");
 	exit(1);
@@ -166,6 +166,7 @@
 	char *filename = NULL;
 
 	char *tempstr = NULL;
+	char *pparam = NULL;
 
 	print_version();
 	print_banner();
@@ -287,10 +288,10 @@
 				if (strncmp(optarg, name, namelen) == 0) {
 					switch (optarg[namelen]) {
 					case ':':
-						programmer_param = strdup(optarg + namelen + 1);
-						if (!strlen(programmer_param)) {
-							free(programmer_param);
-							programmer_param = NULL;
+						pparam = strdup(optarg + namelen + 1);
+						if (!strlen(pparam)) {
+							free(pparam);
+							pparam = NULL;
 						}
 						break;
 					case '\0':
@@ -381,9 +382,7 @@
 	/* FIXME: Delay calibration should happen in programmer code. */
 	myusec_calibrate_delay();
 
-	msg_pdbg("Initializing %s programmer\n",
-		 programmer_table[programmer].name);
-	if (programmer_init()) {
+	if (programmer_init(pparam)) {
 		fprintf(stderr, "Error: Programmer initialization failed.\n");
 		exit(1);
 	}