Use struct flashctx instead of struct flashchip for flash chip access

Struct flashchip is used only for the flashchips array and for
operations which do not access hardware, e.g. printing a list of
supported flash chips.

struct flashctx (flash context) contains all data available in
struct flashchip, but it also contains runtime information like
mapping addresses. struct flashctx is expected to grow additional
members over time, a prime candidate being programmer info.
struct flashctx contains all of struct flashchip with identical
member layout, but struct flashctx has additional members at the end.

The separation between struct flashchip/flashctx shrinks the memory
requirement of the big flashchips array and allows future extension
of flashctx without having to worry about bloat.

Corresponding to flashrom svn r1473.

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/spi25.c b/spi25.c
index 60eb644..abcf6d0 100644
--- a/spi25.c
+++ b/spi25.c
@@ -113,7 +113,7 @@
 	return spi_send_command(sizeof(cmd), 0, cmd, NULL);
 }
 
-static int probe_spi_rdid_generic(struct flashchip *flash, int bytes)
+static int probe_spi_rdid_generic(struct flashctx *flash, int bytes)
 {
 	unsigned char readarr[4];
 	uint32_t id1;
@@ -167,12 +167,12 @@
 	return 0;
 }
 
-int probe_spi_rdid(struct flashchip *flash)
+int probe_spi_rdid(struct flashctx *flash)
 {
 	return probe_spi_rdid_generic(flash, 3);
 }
 
-int probe_spi_rdid4(struct flashchip *flash)
+int probe_spi_rdid4(struct flashctx *flash)
 {
 	/* Some SPI controllers do not support commands with writecnt=1 and
 	 * readcnt=4.
@@ -194,7 +194,7 @@
 	return 0;
 }
 
-int probe_spi_rems(struct flashchip *flash)
+int probe_spi_rems(struct flashctx *flash)
 {
 	unsigned char readarr[JEDEC_REMS_INSIZE];
 	uint32_t id1, id2;
@@ -230,7 +230,7 @@
 	return 0;
 }
 
-int probe_spi_res1(struct flashchip *flash)
+int probe_spi_res1(struct flashctx *flash)
 {
 	static const unsigned char allff[] = {0xff, 0xff, 0xff};
 	static const unsigned char all00[] = {0x00, 0x00, 0x00};
@@ -274,7 +274,7 @@
 	return 1;
 }
 
-int probe_spi_res2(struct flashchip *flash)
+int probe_spi_res2(struct flashctx *flash)
 {
 	unsigned char readarr[2];
 	uint32_t id1, id2;
@@ -410,7 +410,7 @@
 		bpt[(status & 0x1c) >> 2]);
 }
 
-int spi_prettyprint_status_register(struct flashchip *flash)
+int spi_prettyprint_status_register(struct flashctx *flash)
 {
 	uint8_t status;
 
@@ -444,7 +444,7 @@
 	return 0;
 }
 
-int spi_chip_erase_60(struct flashchip *flash)
+int spi_chip_erase_60(struct flashctx *flash)
 {
 	int result;
 	struct spi_command cmds[] = {
@@ -481,7 +481,7 @@
 	return 0;
 }
 
-int spi_chip_erase_c7(struct flashchip *flash)
+int spi_chip_erase_c7(struct flashctx *flash)
 {
 	int result;
 	struct spi_command cmds[] = {
@@ -517,7 +517,7 @@
 	return 0;
 }
 
-int spi_block_erase_52(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_52(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
 {
 	int result;
 	struct spi_command cmds[] = {
@@ -563,7 +563,7 @@
  * 32k for SST
  * 4-32k non-uniform for EON
  */
-int spi_block_erase_d8(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_d8(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
 {
 	int result;
 	struct spi_command cmds[] = {
@@ -607,7 +607,7 @@
 /* Block size is usually
  * 4k for PMC
  */
-int spi_block_erase_d7(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_d7(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
 {
 	int result;
 	struct spi_command cmds[] = {
@@ -649,7 +649,7 @@
 }
 
 /* Sector size is usually 4k, though Macronix eliteflash has 64k */
-int spi_block_erase_20(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_20(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
 {
 	int result;
 	struct spi_command cmds[] = {
@@ -690,7 +690,7 @@
 	return 0;
 }
 
-int spi_block_erase_60(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_60(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
 {
 	if ((addr != 0) || (blocklen != flash->total_size * 1024)) {
 		msg_cerr("%s called with incorrect arguments\n",
@@ -700,7 +700,7 @@
 	return spi_chip_erase_60(flash);
 }
 
-int spi_block_erase_c7(struct flashchip *flash, unsigned int addr, unsigned int blocklen)
+int spi_block_erase_c7(struct flashctx *flash, unsigned int addr, unsigned int blocklen)
 {
 	if ((addr != 0) || (blocklen != flash->total_size * 1024)) {
 		msg_cerr("%s called with incorrect arguments\n",
@@ -728,7 +728,7 @@
  * This is according the SST25VF016 datasheet, who knows it is more
  * generic that this...
  */
-static int spi_write_status_register_ewsr(struct flashchip *flash, int status)
+static int spi_write_status_register_ewsr(struct flashctx *flash, int status)
 {
 	int result;
 	int i = 0;
@@ -776,7 +776,7 @@
 	return 0;
 }
 
-static int spi_write_status_register_wren(struct flashchip *flash, int status)
+static int spi_write_status_register_wren(struct flashctx *flash, int status)
 {
 	int result;
 	int i = 0;
@@ -824,7 +824,7 @@
 	return 0;
 }
 
-int spi_write_status_register(struct flashchip *flash, int status)
+int spi_write_status_register(struct flashctx *flash, int status)
 {
 	int ret = 1;
 
@@ -926,7 +926,7 @@
  * Write 0x00 to the status register. Check if any locks are still set (that
  * part is chip specific). Repeat once.
  */
-int spi_disable_blockprotect(struct flashchip *flash)
+int spi_disable_blockprotect(struct flashctx *flash)
 {
 	uint8_t status;
 	int result;
@@ -968,7 +968,7 @@
  * FIXME: Use the chunk code from Michael Karcher instead.
  * Each page is read separately in chunks with a maximum size of chunksize.
  */
-int spi_read_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
+int spi_read_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
 {
 	int rc = 0;
 	unsigned int i, j, starthere, lenhere, toread;
@@ -1007,12 +1007,12 @@
  * FIXME: Use the chunk code from Michael Karcher instead.
  * Each page is written separately in chunks with a maximum size of chunksize.
  */
-int spi_write_chunked(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
+int spi_write_chunked(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len, unsigned int chunksize)
 {
 	int rc = 0;
 	unsigned int i, j, starthere, lenhere, towrite;
 	/* FIXME: page_size is the wrong variable. We need max_writechunk_size
-	 * in struct flashchip to do this properly. All chips using
+	 * in struct flashctx to do this properly. All chips using
 	 * spi_chip_write_256 have page_size set to max_writechunk_size, so
 	 * we're OK for now.
 	 */
@@ -1055,7 +1055,7 @@
  * (e.g. due to size constraints in IT87* for over 512 kB)
  */
 /* real chunksize is 1, logical chunksize is 1 */
-int spi_chip_write_1(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int spi_chip_write_1(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
 {
 	unsigned int i;
 	int result = 0;
@@ -1071,7 +1071,7 @@
 	return 0;
 }
 
-int spi_aai_write(struct flashchip *flash, uint8_t *buf, unsigned int start, unsigned int len)
+int spi_aai_write(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
 {
 	uint32_t pos = start;
 	int result;