mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-29 16:03:47 +02:00
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>
This commit is contained in:
parent
9fa68b0cfd
commit
9420043986
53
flashrom.c
53
flashrom.c
@ -1047,7 +1047,32 @@ static int write_buf_to_include_args(const struct flashctx *const flash,
|
|||||||
return 0;
|
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)
|
int read_flash_to_file(struct flashctx *flash, const char *filename)
|
||||||
{
|
{
|
||||||
unsigned long size = flash->chip->total_size * 1024;
|
unsigned long size = flash->chip->total_size * 1024;
|
||||||
@ -1148,32 +1173,6 @@ static int selfcheck_eraseblocks(const struct flashchip *chip)
|
|||||||
return ret;
|
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);
|
typedef int (*erasefn_t)(struct flashctx *, unsigned int addr, unsigned int len);
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
|
Loading…
x
Reference in New Issue
Block a user