mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-26 22:52:34 +02:00
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>
This commit is contained in:
parent
759a056673
commit
e924dc0616
20
rayer_spi.c
20
rayer_spi.c
@ -254,12 +254,13 @@ static const struct rayer_programmer *find_progtype(const char *prog_type)
|
||||
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 @@ static int get_params(const struct programmer_cfg *cfg, uint16_t *lpt_iobase, ch
|
||||
}
|
||||
|
||||
arg = extract_programmer_param_str(cfg, "type");
|
||||
if (arg) {
|
||||
*prog_type = strdup(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",
|
||||
|
Loading…
x
Reference in New Issue
Block a user