Edward O'Callaghan submitted this change.

View Change


Approvals: build bot (Jenkins): Verified Angel Pons: Looks good to me, approved Edward O'Callaghan: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved
rayer_spi.c: Get rid of temporary `prog_type` string

Make the `get_params()` function provide a pointer to `struct
rayer_programmer` directly, instead of having a `prog_type` string
passed around three functions.

Change-Id: I83e34382ee9814f224025e21e5099fdab73cee8c
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/68239
Reviewed-by: Edward O'Callaghan <quasisec@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
---
M rayer_spi.c
1 file changed, 26 insertions(+), 14 deletions(-)

diff --git a/rayer_spi.c b/rayer_spi.c
index 9be41e7..27caf2b 100644
--- a/rayer_spi.c
+++ b/rayer_spi.c
@@ -254,12 +254,13 @@
return prog;
}

-static int get_params(const struct programmer_cfg *cfg, uint16_t *lpt_iobase, char **prog_type)
+static int get_params(const struct programmer_cfg *cfg, uint16_t *lpt_iobase,
+ const struct rayer_programmer **prog)
{
/* Pick a default value for the I/O base. */
*lpt_iobase = 0x378;
/* no programmer type specified. */
- *prog_type = NULL;
+ *prog = NULL;

/* Non-default port requested? */
char *arg = extract_programmer_param_str(cfg, "iobase");
@@ -289,26 +290,19 @@
}

arg = extract_programmer_param_str(cfg, "type");
- if (arg) {
- *prog_type = strdup(arg);
- free(arg);
- }
+ *prog = find_progtype(arg);
+ free(arg);

- return 0;
+ return *prog ? 0 : -1;
}

static int rayer_spi_init(const struct programmer_cfg *cfg)
{
+ const struct rayer_programmer *prog;
struct rayer_pinout *pinout = NULL;
uint16_t lpt_iobase;
- char *prog_type;

- if (get_params(cfg, &lpt_iobase, &prog_type) < 0)
- return 1;
-
- const struct rayer_programmer *prog = find_progtype(prog_type);
- free(prog_type);
- if (!prog)
+ if (get_params(cfg, &lpt_iobase, &prog) < 0)
return 1;

msg_pdbg("Using address 0x%x as I/O base for parallel port access.\n",

To view, visit change 68239. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I83e34382ee9814f224025e21e5099fdab73cee8c
Gerrit-Change-Number: 68239
Gerrit-PatchSet: 4
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Angel Pons <th3fanbus@gmail.com>
Gerrit-Reviewer: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger@posteo.net>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged