1
0
mirror of https://review.coreboot.org/flashrom.git synced 2025-07-01 14:11:15 +02:00

flashrom.c: flatten out read_buf_from_include_args()

read_buf_from_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: Ieadd68895c7ba05cc3d770d304351b02622f14d7
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/66633
Reviewed-by: Evan Benn <evanbenn@google.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Nico Huber <nico.h@gmx.de>
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-11 22:02:26 +10:00
committed by Edward O'Callaghan
parent 75b7455441
commit ac7f0c20b8
3 changed files with 5 additions and 7 deletions

View File

@ -411,7 +411,7 @@ static int do_write(struct flashctx *const flash, const char *const filename, co
* ... then update newcontents with contents from files provided to '-i' * ... then update newcontents with contents from files provided to '-i'
* args if needed. * args if needed.
*/ */
if (read_buf_from_include_args(flash, newcontents)) if (read_buf_from_include_args(get_layout(flash), newcontents))
goto _free_ret; goto _free_ret;
if (referencefile) { if (referencefile) {
@ -445,7 +445,7 @@ static int do_verify(struct flashctx *const flash, const char *const filename)
* ... then update newcontents with contents from files provided to '-i' * ... then update newcontents with contents from files provided to '-i'
* args if needed. * args if needed.
*/ */
if (read_buf_from_include_args(flash, newcontents)) if (read_buf_from_include_args(get_layout(flash), newcontents))
goto _free_ret; goto _free_ret;
ret = flashrom_image_verify(flash, newcontents, flash_size); ret = flashrom_image_verify(flash, newcontents, flash_size);

View File

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

View File

@ -423,7 +423,7 @@ void print_banner(void);
void list_programmers_linebreak(int startcol, int cols, int paren); void list_programmers_linebreak(int startcol, int cols, int paren);
int selfcheck(void); int selfcheck(void);
int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename); int read_buf_from_file(unsigned char *buf, unsigned long size, const char *filename);
int read_buf_from_include_args(const struct flashctx *const flash, unsigned char *buf); 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_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 flashctx *const flash, unsigned char *buf);
int prepare_flash_access(struct flashctx *, bool read_it, bool write_it, bool erase_it, bool verify_it); int prepare_flash_access(struct flashctx *, bool read_it, bool write_it, bool erase_it, bool verify_it);