Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/56297 )
Change subject: flashrom.c: Reorder read_by_layout() to avoid forward decl ......................................................................
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 --- M flashrom.c 1 file changed, 26 insertions(+), 27 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/97/56297/1
diff --git a/flashrom.c b/flashrom.c index 8d44c3d..debe60c 100644 --- a/flashrom.c +++ b/flashrom.c @@ -1047,7 +1047,32 @@ 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 @@ 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