1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-04-27 23:22:37 +02:00

flashrom.c: flatten out write_buf_to_include_args()

write_buf_to_include_args() does not need the whole flashctx,
rather it works with a fix layout and buffer. Just pass what
state is actually required.

BUG=b:242246291
TEST=builds

Change-Id: I885c4395356eef27746c66300233f07f4718ccdf
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66644
Reviewed-by: Evan Benn <evanbenn@google.com>
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nikolai Artemiev <nartemiev@google.com>
Reviewed-by: Sam McNally <sammc@google.com>
Reviewed-by: Thomas Heijligen <src@posteo.de>
This commit is contained in:
Edward O'Callaghan 2022-08-12 11:24:11 +10:00 committed by Edward O'Callaghan
parent ac7f0c20b8
commit eb1b1f6f7d
3 changed files with 4 additions and 6 deletions

View File

@ -373,7 +373,7 @@ static int do_read(struct flashctx *const flash, const char *const filename)
if (ret > 0)
goto free_out;
if (write_buf_to_include_args(flash, buf)) {
if (write_buf_to_include_args(get_layout(flash), buf)) {
ret = 1;
goto free_out;
}

View File

@ -1021,14 +1021,12 @@ out:
* then this will write files using data from the corresponding region in the
* supplied buffer.
*
* @param flashctx Flash context to be used.
* @param layout The layout to be used.
* @param buf Chip-sized buffer to read data from
* @return 0 on success
*/
int write_buf_to_include_args(const struct flashctx *const flash,
unsigned char *buf)
int write_buf_to_include_args(const struct flashrom_layout *const layout, unsigned char *buf)
{
const struct flashrom_layout *const layout = get_layout(flash);
const struct romentry *entry = NULL;
while ((entry = layout_next_included(layout, entry))) {

View File

@ -425,7 +425,7 @@ int selfcheck(void);
int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename);
int read_buf_from_include_args(const struct flashrom_layout *const layout, unsigned char *buf);
int write_buf_to_file(const unsigned char *buf, unsigned long size, const char *filename);
int write_buf_to_include_args(const struct flashctx *const flash, unsigned char *buf);
int write_buf_to_include_args(const struct flashrom_layout *const layout, unsigned char *buf);
int prepare_flash_access(struct flashctx *, bool read_it, bool write_it, bool erase_it, bool verify_it);
void finalize_flash_access(struct flashctx *);
int register_chip_restore(chip_restore_fn_cb_t func, struct flashctx *flash, uint8_t status);