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/jedec.c b/jedec.c
index 30c343f..05cba79 100644
--- a/jedec.c
+++ b/jedec.c
@@ -38,7 +38,7 @@
 	return (val ^ (val >> 1)) & 0x1;
 }
 
-void toggle_ready_jedec_common(chipaddr dst, int delay)
+static void toggle_ready_jedec_common(chipaddr dst, int delay)
 {
 	unsigned int i = 0;
 	uint8_t tmp1, tmp2;
@@ -70,7 +70,7 @@
  * Given that erase is slow on all chips, it is recommended to use 
  * toggle_ready_jedec_slow in erase functions.
  */
-void toggle_ready_jedec_slow(chipaddr dst)
+static void toggle_ready_jedec_slow(chipaddr dst)
 {
 	toggle_ready_jedec_common(dst, 8 * 1000);
 }
@@ -92,7 +92,7 @@
 		msg_cdbg("%s: excessive loops, i=0x%x\n", __func__, i);
 }
 
-void start_program_jedec_common(struct flashchip *flash, unsigned int mask)
+static void start_program_jedec_common(struct flashchip *flash, unsigned int mask)
 {
 	chipaddr bios = flash->virtual_memory;
 	chip_writeb(0xAA, bios + (0x5555 & mask));
@@ -100,7 +100,7 @@
 	chip_writeb(0xA0, bios + (0x5555 & mask));
 }
 
-int probe_jedec_common(struct flashchip *flash, unsigned int mask)
+static int probe_jedec_common(struct flashchip *flash, unsigned int mask)
 {
 	chipaddr bios = flash->virtual_memory;
 	uint8_t id1, id2;
@@ -199,7 +199,7 @@
 	return 1;
 }
 
-int erase_sector_jedec_common(struct flashchip *flash, unsigned int page,
+static int erase_sector_jedec_common(struct flashchip *flash, unsigned int page,
 			      unsigned int pagesize, unsigned int mask)
 {
 	chipaddr bios = flash->virtual_memory;
@@ -229,7 +229,7 @@
 	return 0;
 }
 
-int erase_block_jedec_common(struct flashchip *flash, unsigned int block,
+static int erase_block_jedec_common(struct flashchip *flash, unsigned int block,
 			     unsigned int blocksize, unsigned int mask)
 {
 	chipaddr bios = flash->virtual_memory;
@@ -259,7 +259,7 @@
 	return 0;
 }
 
-int erase_chip_jedec_common(struct flashchip *flash, unsigned int mask)
+static int erase_chip_jedec_common(struct flashchip *flash, unsigned int mask)
 {
 	int total_size = flash->total_size * 1024;
 	chipaddr bios = flash->virtual_memory;
@@ -288,7 +288,7 @@
 	return 0;
 }
 
-int write_byte_program_jedec_common(struct flashchip *flash, uint8_t *src,
+static int write_byte_program_jedec_common(struct flashchip *flash, uint8_t *src,
 			     chipaddr dst, unsigned int mask)
 {
 	int tried = 0, failed = 0;
@@ -335,7 +335,7 @@
 	return failed;
 }
 
-int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src,
+static int write_page_write_jedec_common(struct flashchip *flash, uint8_t *src,
 			   int start, int page_size, unsigned int mask)
 {
 	int i, tried = 0, failed;
@@ -374,7 +374,7 @@
 	return failed;
 }
 
-int getaddrmask(struct flashchip *flash)
+static int getaddrmask(struct flashchip *flash)
 {
 	switch (flash->feature_bits & FEATURE_ADDR_MASK) {
 	case FEATURE_ADDR_FULL: