Edward O'Callaghan has uploaded this change for review.
serprog.c: Dispense with forward decl by reshuffle
Change-Id: I0ffcd8bd03fae0d905887a88c9b2e06f61577fd4
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
---
M serprog.c
1 file changed, 41 insertions(+), 33 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/43/70443/1
diff --git a/serprog.c b/serprog.c
index a7796ba..8d24b5a 100644
--- a/serprog.c
+++ b/serprog.c
@@ -453,7 +453,37 @@
return NULL;
}
-static void serprog_delay(const struct flashctx *flash, unsigned int usecs);
+static int sp_check_opbuf_usage(int bytes_to_be_added)
+{
+ if (sp_device_opbuf_size <= (sp_opbuf_usage + bytes_to_be_added)) {
+ /* If this happens in the middle of a page load the page load will probably fail. */
+ msg_pwarn(MSGHEADER "Warning: executed operation buffer due to size reasons\n");
+ if (sp_execute_opbuf() != 0)
+ return 1;
+ }
+ return 0;
+}
+
+static void serprog_delay(const struct flashctx *flash, unsigned int usecs)
+{
+ unsigned char buf[4];
+ msg_pspew("%s usecs=%d\n", __func__, usecs);
+ if (!sp_check_commandavail(S_CMD_O_DELAY)) {
+ msg_pdbg2("serprog_delay used, but programmer doesn't support delays natively - emulating\n");
+ internal_delay(usecs);
+ return;
+ }
+ if ((sp_max_write_n) && (sp_write_n_bytes))
+ sp_pass_writen();
+ sp_check_opbuf_usage(5);
+ buf[0] = ((usecs >> 0) & 0xFF);
+ buf[1] = ((usecs >> 8) & 0xFF);
+ buf[2] = ((usecs >> 16) & 0xFF);
+ buf[3] = ((usecs >> 24) & 0xFF);
+ sp_stream_buffer_op(S_CMD_O_DELAY, 4, buf);
+ sp_opbuf_usage += 5;
+ sp_prev_was_write = 0;
+}
static struct spi_master spi_master_serprog = {
.map_flash_region = serprog_map,
@@ -469,17 +499,6 @@
.delay = serprog_delay,
};
-static int sp_check_opbuf_usage(int bytes_to_be_added)
-{
- if (sp_device_opbuf_size <= (sp_opbuf_usage + bytes_to_be_added)) {
- /* If this happens in the middle of a page load the page load will probably fail. */
- msg_pwarn(MSGHEADER "Warning: executed operation buffer due to size reasons\n");
- if (sp_execute_opbuf() != 0)
- return 1;
- }
- return 0;
-}
-
static void serprog_chip_writeb(const struct flashctx *flash, uint8_t val,
chipaddr addr)
{
@@ -571,27 +590,6 @@
sp_do_read_n(&(buf[addrm-addr]), addrm, lenm); // FIXME: return error
}
-static void serprog_delay(const struct flashctx *flash, unsigned int usecs)
-{
- unsigned char buf[4];
- msg_pspew("%s usecs=%d\n", __func__, usecs);
- if (!sp_check_commandavail(S_CMD_O_DELAY)) {
- msg_pdbg2("serprog_delay used, but programmer doesn't support delays natively - emulating\n");
- internal_delay(usecs);
- return;
- }
- if ((sp_max_write_n) && (sp_write_n_bytes))
- sp_pass_writen();
- sp_check_opbuf_usage(5);
- buf[0] = ((usecs >> 0) & 0xFF);
- buf[1] = ((usecs >> 8) & 0xFF);
- buf[2] = ((usecs >> 16) & 0xFF);
- buf[3] = ((usecs >> 24) & 0xFF);
- sp_stream_buffer_op(S_CMD_O_DELAY, 4, buf);
- sp_opbuf_usage += 5;
- sp_prev_was_write = 0;
-}
-
static const struct par_master par_master_serprog = {
.map_flash_region = serprog_map,
.chip_readb = serprog_chip_readb,
To view, visit change 70443. To unsubscribe, or for help writing mail filters, visit settings.