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/sst49lfxxxc.c b/sst49lfxxxc.c
index c15b56b..2f14b7a 100644
--- a/sst49lfxxxc.c
+++ b/sst49lfxxxc.c
@@ -23,7 +23,7 @@
 #include "flash.h"
 #include "chipdrivers.h"
 
-int unlock_block_49lfxxxc(struct flashchip *flash, unsigned long address, unsigned char bits)
+static int write_lockbits_block_49lfxxxc(struct flashchip *flash, unsigned long address, unsigned char bits)
 {
 	unsigned long lock = flash->virtual_registers + address + 2;
 	msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n", lock, chip_readb(lock));
@@ -40,31 +40,16 @@
 
 	msg_cdbg("\nbios=0x%08lx\n", registers);
 	for (i = 0; left > 65536; i++, left -= 65536) {
-		msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n",
-			     registers + (i * 65536) + 2,
-			     chip_readb(registers + (i * 65536) + 2));
-		chip_writeb(bits, registers + (i * 65536) + 2);
+		write_lockbits_block_49lfxxxc(flash, i * 65536, bits);
 	}
 	address = i * 65536;
-	msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n",
-		     registers + address + 2,
-		     chip_readb(registers + address + 2));
-	chip_writeb(bits, registers + address + 2);
+	write_lockbits_block_49lfxxxc(flash, address, bits);
 	address += 32768;
-	msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n",
-		     registers + address + 2,
-		     chip_readb(registers + address + 2));
-	chip_writeb(bits, registers + address + 2);
+	write_lockbits_block_49lfxxxc(flash, address, bits);
 	address += 8192;
-	msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n",
-		     registers + address + 2,
-		     chip_readb(registers + address + 2));
-	chip_writeb(bits, registers + address + 2);
+	write_lockbits_block_49lfxxxc(flash, address, bits);
 	address += 8192;
-	msg_cdbg("lockbits at address=0x%08lx is 0x%01x\n",
-		     registers + address + 2,
-		     chip_readb(registers + address + 2));
-	chip_writeb(bits, registers + address + 2);
+	write_lockbits_block_49lfxxxc(flash, address, bits);
 
 	return 0;
 }