From 16744f9e96d0f1e203d4a67ad2bfd0c50e3c437a Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Fri, 12 Aug 2022 11:30:27 +1000 Subject: flashrom.c: Move write_buf_to_include_args() to cli_classic.c The write_buf_to_include_args() helper is only ever used by the cli frontend therefore make it static local to the user. BUG=b:242246291 TEST=builds Change-Id: Ia16bf4b8e46a011aa45f98089d43904b077833a0 Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/66648 Tested-by: build bot (Jenkins) Reviewed-by: Evan Benn Reviewed-by: Sam McNally Reviewed-by: Thomas Heijligen --- cli_classic.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) (limited to 'cli_classic.c') diff --git a/cli_classic.c b/cli_classic.c index 267f3c611..bac31d1c1 100644 --- a/cli_classic.c +++ b/cli_classic.c @@ -392,6 +392,33 @@ static int read_buf_from_include_args(const struct flashrom_layout *const layout return 0; } +/** + * @brief Writes content from buffer to one or more files. + * + * Writes content from supplied buffer to files. If a filename is specified for + * individual regions using the partial read syntax ('-i [:]') + * then this will write files using data from the corresponding region in the + * supplied buffer. + * + * @param layout The layout to be used. + * @param buf Chip-sized buffer to read data from + * @return 0 on success + */ +static int write_buf_to_include_args(const struct flashrom_layout *const layout, unsigned char *buf) +{ + const struct romentry *entry = NULL; + + while ((entry = layout_next_included(layout, entry))) { + if (!entry->file) + continue; + if (write_buf_to_file(buf + entry->start, + entry->end - entry->start + 1, entry->file)) + return 1; + } + + return 0; +} + static int do_read(struct flashctx *const flash, const char *const filename) { int ret; -- cgit v1.2.3