aboutsummaryrefslogtreecommitdiffstats
path: root/flashrom.c
diff options
context:
space:
mode:
authorEdward O'Callaghan <quasisec@google.com>2021-07-14 15:16:31 +1000
committerEdward O'Callaghan <quasisec@chromium.org>2021-07-16 02:10:54 +0000
commit942004398632e8e71e2b29ee476233be569615ba (patch)
treedbfc1b72c327d2557dd1486d17c80355423c0757 /flashrom.c
parent9fa68b0cfd2f8d148ae841ae5faeb86281b04b42 (diff)
downloadflashrom-942004398632e8e71e2b29ee476233be569615ba.tar.gz
flashrom-942004398632e8e71e2b29ee476233be569615ba.tar.bz2
flashrom-942004398632e8e71e2b29ee476233be569615ba.zip
flashrom.c: Reorder read_by_layout() to avoid forward decl
Help make groking flashrom.c fractionaly easier. BUG=none BRANCH=none TEST=builds Change-Id: Ifd6c152e3a1d84b59a876997e543127387f24d40 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/56297 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Diffstat (limited to 'flashrom.c')
-rw-r--r--flashrom.c53
1 files changed, 26 insertions, 27 deletions
diff --git a/flashrom.c b/flashrom.c
index 8d44c3d4..debe60c3 100644
--- a/flashrom.c
+++ b/flashrom.c
@@ -1047,7 +1047,32 @@ static int write_buf_to_include_args(const struct flashctx *const flash,
return 0;
}
-static int read_by_layout(struct flashctx *, uint8_t *);
+/**
+ * @brief Reads the included layout regions into a buffer.
+ *
+ * If there is no layout set in the given flash context, the whole chip will
+ * be read.
+ *
+ * @param flashctx Flash context to be used.
+ * @param buffer Buffer of full chip size to read into.
+ * @return 0 on success,
+ * 1 if any read fails.
+ */
+static int read_by_layout(struct flashctx *const flashctx, uint8_t *const buffer)
+{
+ const struct flashrom_layout *const layout = get_layout(flashctx);
+ const struct romentry *entry = NULL;
+
+ while ((entry = layout_next_included(layout, entry))) {
+ const chipoff_t region_start = entry->start;
+ const chipsize_t region_len = entry->end - entry->start + 1;
+
+ if (flashctx->chip->read(flashctx, buffer + region_start, region_start, region_len))
+ return 1;
+ }
+ return 0;
+}
+
int read_flash_to_file(struct flashctx *flash, const char *filename)
{
unsigned long size = flash->chip->total_size * 1024;
@@ -1148,32 +1173,6 @@ static int selfcheck_eraseblocks(const struct flashchip *chip)
return ret;
}
-/**
- * @brief Reads the included layout regions into a buffer.
- *
- * If there is no layout set in the given flash context, the whole chip will
- * be read.
- *
- * @param flashctx Flash context to be used.
- * @param buffer Buffer of full chip size to read into.
- * @return 0 on success,
- * 1 if any read fails.
- */
-static int read_by_layout(struct flashctx *const flashctx, uint8_t *const buffer)
-{
- const struct flashrom_layout *const layout = get_layout(flashctx);
- const struct romentry *entry = NULL;
-
- while ((entry = layout_next_included(layout, entry))) {
- const chipoff_t region_start = entry->start;
- const chipsize_t region_len = entry->end - entry->start + 1;
-
- if (flashctx->chip->read(flashctx, buffer + region_start, region_start, region_len))
- return 1;
- }
- return 0;
-}
-
typedef int (*erasefn_t)(struct flashctx *, unsigned int addr, unsigned int len);
/**
* @private