Add struct flashctx * parameter to all functions accessing flash chips
All programmer access function prototypes except init have been made
static and moved to the respective file.
A few internal functions in flash chip drivers had chipaddr parameters
which are no longer needed.
The lines touched by flashctx changes have been adjusted to 80 columns
except in header files.
Corresponding to flashrom svn r1474.
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/serprog.c b/serprog.c
index 539e488..65539a1 100644
--- a/serprog.c
+++ b/serprog.c
@@ -299,7 +299,8 @@
return 0;
}
-static int serprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
+static int serprog_spi_send_command(struct flashctx *flash,
+ unsigned int writecnt, unsigned int readcnt,
const unsigned char *writearr,
unsigned char *readarr);
static int serprog_spi_read(struct flashctx *flash, uint8_t *buf,
@@ -314,6 +315,12 @@
.write_256 = default_spi_write_256,
};
+static void serprog_chip_writeb(const struct flashctx *flash, uint8_t val,
+ chipaddr addr);
+static uint8_t serprog_chip_readb(const struct flashctx *flash,
+ const chipaddr addr);
+static void serprog_chip_readn(const struct flashctx *flash, uint8_t *buf,
+ const chipaddr addr, size_t len);
static const struct par_programmer par_programmer_serprog = {
.chip_readb = serprog_chip_readb,
.chip_readw = fallback_chip_readw,
@@ -680,7 +687,8 @@
}
}
-void serprog_chip_writeb(uint8_t val, chipaddr addr)
+static void serprog_chip_writeb(const struct flashctx *flash, uint8_t val,
+ chipaddr addr)
{
msg_pspew("%s\n", __func__);
if (sp_max_write_n) {
@@ -711,7 +719,8 @@
}
}
-uint8_t serprog_chip_readb(const chipaddr addr)
+static uint8_t serprog_chip_readb(const struct flashctx *flash,
+ const chipaddr addr)
{
unsigned char c;
unsigned char buf[3];
@@ -757,7 +766,8 @@
}
/* The externally called version that makes sure that max_read_n is obeyed. */
-void serprog_chip_readn(uint8_t * buf, const chipaddr addr, size_t len)
+static void serprog_chip_readn(const struct flashctx *flash, uint8_t * buf,
+ const chipaddr addr, size_t len)
{
size_t lenm = len;
chipaddr addrm = addr;
@@ -792,9 +802,10 @@
sp_prev_was_write = 0;
}
-static int serprog_spi_send_command(unsigned int writecnt, unsigned int readcnt,
- const unsigned char *writearr,
- unsigned char *readarr)
+static int serprog_spi_send_command(struct flashctx *flash,
+ unsigned int writecnt, unsigned int readcnt,
+ const unsigned char *writearr,
+ unsigned char *readarr)
{
unsigned char *parmbuf;
int ret;
@@ -822,14 +833,15 @@
* the advantage that it is much faster for most chips, but breaks those with
* non-contiguous address space (like AT45DB161D). When spi_read_chunked is
* fixed this method can be removed. */
-static int serprog_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len)
+static int serprog_spi_read(struct flashctx *flash, uint8_t *buf,
+ unsigned int start, unsigned int len)
{
unsigned int i, cur_len;
const unsigned int max_read = spi_programmer_serprog.max_data_read;
for (i = 0; i < len; i += cur_len) {
int ret;
cur_len = min(max_read, (len - i));
- ret = spi_nbyte_read(start + i, buf + i, cur_len);
+ ret = spi_nbyte_read(flash, start + i, buf + i, cur_len);
if (ret)
return ret;
}