From 5c710ea54afabf8c0e5f3c8ada45c4a5f9f0781b Mon Sep 17 00:00:00 2001 From: Edward O'Callaghan Date: Fri, 12 Aug 2022 13:47:29 +1000 Subject: tree: Port programmers to pass programmer_cfg to extractors Ran; ``` $ find -name '*.c' -exec sed -i 's/extract_programmer_param_str(NULL/extract_programmer_param_str(cfg/g' '{}' \; ``` Manually fix i2c_helper_linux.c and other cases after. Treat cases of; - pcidev.c , and - usb_device.c as exceptional to be dealt with in later patches. Change-Id: If7b7987e803d35582dda219652a6fc3ed5729b47 Signed-off-by: Edward O'Callaghan Reviewed-on: https://review.coreboot.org/c/flashrom/+/66656 Tested-by: build bot (Jenkins) Reviewed-by: Anastasia Klimchuk Reviewed-by: Felix Singer --- atavia.c | 2 +- buspirate_spi.c | 10 +++++----- chipset_enable.c | 2 +- dediprog.c | 10 +++++----- developerbox_spi.c | 2 +- digilent_spi.c | 4 ++-- dummyflasher.c | 22 +++++++++++----------- ft2232_spi.c | 14 +++++++------- i2c_helper_linux.c | 6 +++--- include/i2c_helper.h | 4 +++- internal.c | 8 ++++---- it87spi.c | 4 ++-- jlink_spi.c | 8 ++++---- linux_mtd.c | 2 +- linux_spi.c | 4 ++-- mediatek_i2c_spi.c | 4 ++-- mstarddc_spi.c | 4 ++-- ni845x_spi.c | 10 +++++----- ogp_spi.c | 2 +- parade_lspcon.c | 4 ++-- pcidev.c | 2 +- pickit2_spi.c | 4 ++-- pony_spi.c | 4 ++-- raiden_debug_spi.c | 6 +++--- rayer_spi.c | 4 ++-- realtek_mst_i2c_spi.c | 8 ++++---- sb600spi.c | 6 +++--- serprog.c | 6 +++--- stlinkv3_spi.c | 4 ++-- usb_device.c | 2 +- 30 files changed, 87 insertions(+), 85 deletions(-) diff --git a/atavia.c b/atavia.c index 45078204..6e64bb45 100644 --- a/atavia.c +++ b/atavia.c @@ -145,7 +145,7 @@ static const struct par_master lpc_master_atavia = { static int atavia_init(const struct programmer_cfg *cfg) { - char *arg = extract_programmer_param_str(NULL, "offset"); + char *arg = extract_programmer_param_str(cfg, "offset"); if (arg) { if (strlen(arg) == 0) { msg_perr("Missing argument for offset.\n"); diff --git a/buspirate_spi.c b/buspirate_spi.c index 8aa72431..8fa60f65 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -332,7 +332,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg) unsigned char *bp_commbuf; int bp_commbufsize; - dev = extract_programmer_param_str(NULL, "dev"); + dev = extract_programmer_param_str(cfg, "dev"); if (dev && !strlen(dev)) { free(dev); dev = NULL; @@ -342,7 +342,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg) return 1; } - tmp = extract_programmer_param_str(NULL, "spispeed"); + tmp = extract_programmer_param_str(cfg, "spispeed"); if (tmp) { for (i = 0; spispeeds[i].name; i++) { if (!strncasecmp(spispeeds[i].name, tmp, strlen(spispeeds[i].name))) { @@ -356,7 +356,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg) free(tmp); /* Extract serialspeed parameter */ - tmp = extract_programmer_param_str(NULL, "serialspeed"); + tmp = extract_programmer_param_str(cfg, "serialspeed"); if (tmp) { for (i = 0; serialspeeds[i].name; i++) { if (!strncasecmp(serialspeeds[i].name, tmp, strlen(serialspeeds[i].name))) { @@ -369,7 +369,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg) } free(tmp); - tmp = extract_programmer_param_str(NULL, "pullups"); + tmp = extract_programmer_param_str(cfg, "pullups"); if (tmp) { if (strcasecmp("on", tmp) == 0) pullup = 1; @@ -380,7 +380,7 @@ static int buspirate_spi_init(const struct programmer_cfg *cfg) } free(tmp); - tmp = extract_programmer_param_str(NULL, "psus"); + tmp = extract_programmer_param_str(cfg, "psus"); if (tmp) { if (strcasecmp("on", tmp) == 0) psu = 1; diff --git a/chipset_enable.c b/chipset_enable.c index 7a98fd47..e57493f4 100644 --- a/chipset_enable.c +++ b/chipset_enable.c @@ -428,7 +428,7 @@ static int enable_flash_ich_fwh_decode(struct pci_dev *dev, enum ich_chipset ich break; } - char *idsel = extract_programmer_param_str(NULL, "fwh_idsel"); + char *idsel = extract_programmer_param_str(NULL, "fwh_idsel"); /* TODO(quasisec): pass prog_param */ if (idsel && strlen(idsel)) { if (!implemented) { msg_perr("Error: fwh_idsel= specified, but (yet) unsupported on this chipset.\n"); diff --git a/dediprog.c b/dediprog.c index cd115056..f957be6d 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1087,7 +1087,7 @@ static int dediprog_init(const struct programmer_cfg *cfg) long target = FLASH_TYPE_APPLICATION_FLASH_1; int i, ret; - param_str = extract_programmer_param_str(NULL, "spispeed"); + param_str = extract_programmer_param_str(cfg, "spispeed"); if (param_str) { for (i = 0; spispeeds[i].name; ++i) { if (!strcasecmp(spispeeds[i].name, param_str)) { @@ -1103,7 +1103,7 @@ static int dediprog_init(const struct programmer_cfg *cfg) free(param_str); } - param_str = extract_programmer_param_str(NULL, "voltage"); + param_str = extract_programmer_param_str(cfg, "voltage"); if (param_str) { millivolt = parse_voltage(param_str); free(param_str); @@ -1112,7 +1112,7 @@ static int dediprog_init(const struct programmer_cfg *cfg) msg_pinfo("Setting voltage to %i mV\n", millivolt); } - param_str = extract_programmer_param_str(NULL, "id"); + param_str = extract_programmer_param_str(cfg, "id"); if (param_str) { char prefix0, prefix1; if (sscanf(param_str, "%c%c%d", &prefix0, &prefix1, &id) != 3) { @@ -1135,7 +1135,7 @@ static int dediprog_init(const struct programmer_cfg *cfg) } free(param_str); - param_str = extract_programmer_param_str(NULL, "device"); + param_str = extract_programmer_param_str(cfg, "device"); if (param_str) { char *dev_suffix; if (id != -1) { @@ -1162,7 +1162,7 @@ static int dediprog_init(const struct programmer_cfg *cfg) } free(param_str); - param_str = extract_programmer_param_str(NULL, "target"); + param_str = extract_programmer_param_str(cfg, "target"); if (param_str) { char *target_suffix; errno = 0; diff --git a/developerbox_spi.c b/developerbox_spi.c index 16fa351f..3774d047 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -152,7 +152,7 @@ static int developerbox_spi_init(const struct programmer_cfg *cfg) return 1; } - char *serialno = extract_programmer_param_str(NULL, "serial"); + char *serialno = extract_programmer_param_str(cfg, "serial"); if (serialno) msg_pdbg("Looking for serial number commencing %s\n", serialno); cp210x_handle = usb_dev_get_by_vid_pid_serial(usb_ctx, diff --git a/digilent_spi.c b/digilent_spi.c index b6e998d5..41342a85 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -408,7 +408,7 @@ static int digilent_spi_init(const struct programmer_cfg *cfg) goto close_handle; } - param_str = extract_programmer_param_str(NULL, "spispeed"); + param_str = extract_programmer_param_str(cfg, "spispeed"); if (param_str) { for (i = 0; spispeeds[i].name; ++i) { if (!strcasecmp(spispeeds[i].name, param_str)) { @@ -424,7 +424,7 @@ static int digilent_spi_init(const struct programmer_cfg *cfg) free(param_str); } - param_str = extract_programmer_param_str(NULL, "reset"); + param_str = extract_programmer_param_str(cfg, "reset"); if (param_str && strlen(param_str)) reset_board = (param_str[0] == '1'); else diff --git a/dummyflasher.c b/dummyflasher.c index bd975240..07fcd724 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -958,7 +958,7 @@ static int init_data(const struct programmer_cfg *cfg, char *status = NULL; int size = -1; /* size for VARIABLE_SIZE chip device */ - bustext = extract_programmer_param_str(NULL, "bus"); + bustext = extract_programmer_param_str(cfg, "bus"); msg_pdbg("Requested buses are: %s\n", bustext ? bustext : "default"); if (!bustext) bustext = strdup("parallel+lpc+fwh+spi+prog"); @@ -990,7 +990,7 @@ static int init_data(const struct programmer_cfg *cfg, msg_pdbg("Support for all flash bus types disabled.\n"); free(bustext); - tmp = extract_programmer_param_str(NULL, "spi_write_256_chunksize"); + tmp = extract_programmer_param_str(cfg, "spi_write_256_chunksize"); if (tmp) { data->spi_write_256_chunksize = strtoul(tmp, &endptr, 0); if (*endptr != '\0' || data->spi_write_256_chunksize < 1) { @@ -1001,7 +1001,7 @@ static int init_data(const struct programmer_cfg *cfg, } free(tmp); - tmp = extract_programmer_param_str(NULL, "spi_blacklist"); + tmp = extract_programmer_param_str(cfg, "spi_blacklist"); if (tmp) { i = strlen(tmp); if (!strncmp(tmp, "0x", 2)) { @@ -1037,7 +1037,7 @@ static int init_data(const struct programmer_cfg *cfg, } free(tmp); - tmp = extract_programmer_param_str(NULL, "spi_ignorelist"); + tmp = extract_programmer_param_str(cfg, "spi_ignorelist"); if (tmp) { i = strlen(tmp); if (!strncmp(tmp, "0x", 2)) { @@ -1074,7 +1074,7 @@ static int init_data(const struct programmer_cfg *cfg, free(tmp); /* frequency to emulate in Hz (default), KHz, or MHz */ - tmp = extract_programmer_param_str(NULL, "freq"); + tmp = extract_programmer_param_str(cfg, "freq"); if (tmp) { unsigned long int freq; char *units = tmp; @@ -1124,7 +1124,7 @@ static int init_data(const struct programmer_cfg *cfg, } free(tmp); - tmp = extract_programmer_param_str(NULL, "size"); + tmp = extract_programmer_param_str(cfg, "size"); if (tmp) { size = strtol(tmp, NULL, 10); if (size <= 0 || (size % 1024 != 0)) { @@ -1136,7 +1136,7 @@ static int init_data(const struct programmer_cfg *cfg, free(tmp); } - tmp = extract_programmer_param_str(NULL, "hwwp"); + tmp = extract_programmer_param_str(cfg, "hwwp"); if (tmp) { if (!strcmp(tmp, "yes")) { msg_pdbg("Emulated chip will have hardware WP enabled\n"); @@ -1151,7 +1151,7 @@ static int init_data(const struct programmer_cfg *cfg, free(tmp); } - tmp = extract_programmer_param_str(NULL, "emulate"); + tmp = extract_programmer_param_str(cfg, "emulate"); if (!tmp) { if (size != -1) { msg_perr("%s: size parameter is only valid for VARIABLE_SIZE chip.\n", __func__); @@ -1275,7 +1275,7 @@ static int init_data(const struct programmer_cfg *cfg, free(tmp); /* Should emulated flash erase to zero (yes/no)? */ - tmp = extract_programmer_param_str(NULL, "erase_to_zero"); + tmp = extract_programmer_param_str(cfg, "erase_to_zero"); if (tmp) { if (data->emu_chip != EMULATE_VARIABLE_SIZE) { msg_perr("%s: erase_to_zero parameter is not valid for real chip.\n", __func__); @@ -1295,7 +1295,7 @@ static int init_data(const struct programmer_cfg *cfg, } free(tmp); - status = extract_programmer_param_str(NULL, "spi_status"); + status = extract_programmer_param_str(cfg, "spi_status"); if (status) { unsigned int emu_status; @@ -1371,7 +1371,7 @@ static int dummy_init(const struct programmer_cfg *cfg) memset(data->flashchip_contents, data->erase_to_zero ? 0x00 : 0xff, data->emu_chip_size); /* Will be freed by shutdown function if necessary. */ - data->emu_persistent_image = extract_programmer_param_str(NULL, "image"); + data->emu_persistent_image = extract_programmer_param_str(cfg, "image"); if (!data->emu_persistent_image) { /* Nothing else to do. */ goto dummy_init_out; diff --git a/ft2232_spi.c b/ft2232_spi.c index c7dbbb2a..2971c2eb 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -340,7 +340,7 @@ static int ft2232_spi_init(const struct programmer_cfg *cfg) struct ftdi_context ftdic; struct ft2232_data *spi_data; - arg = extract_programmer_param_str(NULL, "type"); + arg = extract_programmer_param_str(cfg, "type"); if (arg) { if (!strcasecmp(arg, "2232H")) { ft2232_type = FTDI_FT2232H_PID; @@ -447,7 +447,7 @@ static int ft2232_spi_init(const struct programmer_cfg *cfg) /* Remember reserved pins before pindir gets modified. */ const uint8_t rsv_bits = pindir & 0xf0; - arg = extract_programmer_param_str(NULL, "port"); + arg = extract_programmer_param_str(cfg, "port"); if (arg) { switch (toupper((unsigned char)*arg)) { case 'A': @@ -480,7 +480,7 @@ static int ft2232_spi_init(const struct programmer_cfg *cfg) } free(arg); - arg = extract_programmer_param_str(NULL, "divisor"); + arg = extract_programmer_param_str(cfg, "divisor"); if (arg && strlen(arg)) { unsigned int temp = 0; char *endptr; @@ -496,7 +496,7 @@ static int ft2232_spi_init(const struct programmer_cfg *cfg) free(arg); bool csgpiol_set = false; - arg = extract_programmer_param_str(NULL, "csgpiol"); + arg = extract_programmer_param_str(cfg, "csgpiol"); if (arg) { csgpiol_set = true; msg_pwarn("Deprecation warning: `csgpiol` is deprecated and will be removed " @@ -529,7 +529,7 @@ static int ft2232_spi_init(const struct programmer_cfg *cfg) for (int pin = 0; pin < 4; pin++) { char gpiol_param[7]; snprintf(gpiol_param, sizeof(gpiol_param), "gpiol%d", pin); - arg = extract_programmer_param_str(NULL, gpiol_param); + arg = extract_programmer_param_str(cfg, gpiol_param); if (!arg) continue; @@ -602,8 +602,8 @@ format_error: msg_perr("Unable to select channel (%s).\n", ftdi_get_error_string(&ftdic)); } - arg = extract_programmer_param_str(NULL, "serial"); - arg2 = extract_programmer_param_str(NULL, "description"); + arg = extract_programmer_param_str(cfg, "serial"); + arg2 = extract_programmer_param_str(cfg, "description"); f = ftdi_usb_open_desc(&ftdic, ft2232_vid, ft2232_type, arg2, arg); diff --git a/i2c_helper_linux.c b/i2c_helper_linux.c index 29fdfd41..19b4404f 100644 --- a/i2c_helper_linux.c +++ b/i2c_helper_linux.c @@ -96,12 +96,12 @@ static int get_bus_number(char *bus_str) return bus; } -int i2c_open_from_programmer_params(uint16_t addr, int force) +int i2c_open_from_programmer_params(const struct programmer_cfg *cfg, uint16_t addr, int force) { int fd = -1; - char *bus_str = extract_programmer_param_str(NULL, "bus"); - char *device_path = extract_programmer_param_str(NULL, "devpath"); + char *bus_str = extract_programmer_param_str(cfg, "bus"); + char *device_path = extract_programmer_param_str(cfg, "devpath"); if (device_path != NULL && bus_str != NULL) { msg_perr("%s: only one of bus and devpath may be specified\n", __func__); diff --git a/include/i2c_helper.h b/include/i2c_helper.h index c7d0f7a7..b840b3a9 100644 --- a/include/i2c_helper.h +++ b/include/i2c_helper.h @@ -19,6 +19,8 @@ #include +struct programmer_cfg; /* defined in programmer.h */ + /** * An convenient structure that contains the buffer size and the buffer * pointer. Used to wrap buffer details while doing the I2C data @@ -86,7 +88,7 @@ int i2c_open_path(const char *path, uint16_t addr, int force); * I2C device to use from programmer parameters. It is meant to be called * from I2C-based programmers to avoid repeating parameter parsing code. */ -int i2c_open_from_programmer_params(uint16_t addr, int force); +int i2c_open_from_programmer_params(const struct programmer_cfg *cfg, uint16_t addr, int force); /** * i2c_close - closes the file descriptor returned by i2c_open diff --git a/internal.c b/internal.c index 8b97f53d..18ac088a 100644 --- a/internal.c +++ b/internal.c @@ -129,7 +129,7 @@ static int get_params(const struct programmer_cfg *cfg, *board_vendor = NULL; *board_model = NULL; - arg = extract_programmer_param_str(NULL, "boardenable"); + arg = extract_programmer_param_str(cfg, "boardenable"); if (arg && !strcmp(arg,"force")) { *boardenable = 1; } else if (arg && !strlen(arg)) { @@ -143,7 +143,7 @@ static int get_params(const struct programmer_cfg *cfg, } free(arg); - arg = extract_programmer_param_str(NULL, "boardmismatch"); + arg = extract_programmer_param_str(cfg, "boardmismatch"); if (arg && !strcmp(arg,"force")) { *boardmismatch = 1; } else if (arg && !strlen(arg)) { @@ -157,7 +157,7 @@ static int get_params(const struct programmer_cfg *cfg, } free(arg); - arg = extract_programmer_param_str(NULL, "laptop"); + arg = extract_programmer_param_str(cfg, "laptop"); if (arg && !strcmp(arg, "force_I_want_a_brick")) *force_laptop = 1; else if (arg && !strcmp(arg, "this_is_not_a_laptop")) @@ -173,7 +173,7 @@ static int get_params(const struct programmer_cfg *cfg, } free(arg); - arg = extract_programmer_param_str(NULL, "mainboard"); + arg = extract_programmer_param_str(cfg, "mainboard"); if (arg && strlen(arg)) { if (board_parse_parameter(arg, board_vendor, board_model)) { free(arg); diff --git a/it87spi.c b/it87spi.c index bef60cbb..eb041418 100644 --- a/it87spi.c +++ b/it87spi.c @@ -328,7 +328,7 @@ static uint16_t it87spi_probe(const struct programmer_cfg *cfg, uint16_t port) enter_conf_mode_ite(port); - char *param = extract_programmer_param_str(NULL, "dualbiosindex"); + char *param = extract_programmer_param_str(cfg, "dualbiosindex"); if (param != NULL) { sio_write(port, 0x07, 0x07); /* Select GPIO LDN */ tmp = sio_read(port, 0xEF); @@ -394,7 +394,7 @@ static uint16_t it87spi_probe(const struct programmer_cfg *cfg, uint16_t port) flashport |= sio_read(port, 0x65); msg_pdbg("Serial flash port 0x%04x\n", flashport); /* Non-default port requested? */ - param = extract_programmer_param_str(NULL, "it87spiport"); + param = extract_programmer_param_str(cfg, "it87spiport"); if (param) { char *endptr = NULL; unsigned long forced_flashport; diff --git a/jlink_spi.c b/jlink_spi.c index 48239f3b..52fc7862 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -203,7 +203,7 @@ static int jlink_spi_init(const struct programmer_cfg *cfg) struct jlink_spi_data *jlink_data = NULL; bool enable_target_power; - arg = extract_programmer_param_str(NULL, "spispeed"); + arg = extract_programmer_param_str(cfg, "spispeed"); if (arg) { char *endptr; @@ -230,7 +230,7 @@ static int jlink_spi_init(const struct programmer_cfg *cfg) bool use_serial_number; uint32_t serial_number; - arg = extract_programmer_param_str(NULL, "serial"); + arg = extract_programmer_param_str(cfg, "serial"); if (arg) { if (!strlen(arg)) { @@ -259,7 +259,7 @@ static int jlink_spi_init(const struct programmer_cfg *cfg) free(arg); reset_cs = true; - arg = extract_programmer_param_str(NULL, "cs"); + arg = extract_programmer_param_str(cfg, "cs"); if (arg) { if (!strcasecmp(arg, "reset")) { @@ -281,7 +281,7 @@ static int jlink_spi_init(const struct programmer_cfg *cfg) msg_pdbg("Using TRST as chip select signal.\n"); enable_target_power = false; - arg = extract_programmer_param_str(NULL, "power"); + arg = extract_programmer_param_str(cfg, "power"); if (arg) { if (!strcasecmp(arg, "on")) { diff --git a/linux_mtd.c b/linux_mtd.c index ef908859..c5dc4511 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -500,7 +500,7 @@ static int linux_mtd_init(const struct programmer_cfg *cfg) int ret = 1; struct linux_mtd_data *data = NULL; - param_str = extract_programmer_param_str(NULL, "dev"); + param_str = extract_programmer_param_str(cfg, "dev"); if (param_str) { char *endptr; diff --git a/linux_spi.c b/linux_spi.c index b54ab17a..09ee8a0d 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -177,7 +177,7 @@ static int linux_spi_init(const struct programmer_cfg *cfg) size_t max_kernel_buf_size; struct linux_spi_data *spi_data; - param_str = extract_programmer_param_str(NULL, "spispeed"); + param_str = extract_programmer_param_str(cfg, "spispeed"); if (param_str && strlen(param_str)) { speed_hz = (uint32_t)strtoul(param_str, &endp, 10) * 1000; if (param_str == endp || speed_hz == 0) { @@ -192,7 +192,7 @@ static int linux_spi_init(const struct programmer_cfg *cfg) } free(param_str); - param_str = extract_programmer_param_str(NULL, "dev"); + param_str = extract_programmer_param_str(cfg, "dev"); if (!param_str || !strlen(param_str)) { msg_perr("No SPI device given. Use flashrom -p " "linux_spi:dev=/dev/spidevX.Y\n"); diff --git a/mediatek_i2c_spi.c b/mediatek_i2c_spi.c index c460da18..39a9cea9 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -470,7 +470,7 @@ static int get_params(const struct programmer_cfg *cfg, bool *allow_brick) int ret = 0; *allow_brick = false; /* Default behaviour is to bail. */ - brick_str = extract_programmer_param_str(NULL, "allow_brick"); + brick_str = extract_programmer_param_str(cfg, "allow_brick"); if (brick_str) { if (!strcmp(brick_str, "yes")) { *allow_brick = true; @@ -504,7 +504,7 @@ static int mediatek_init(const struct programmer_cfg *cfg) return SPI_GENERIC_ERROR; } - int fd = i2c_open_from_programmer_params(ISP_PORT, 0); + int fd = i2c_open_from_programmer_params(cfg, ISP_PORT, 0); if (fd < 0) { msg_perr("Failed to open i2c\n"); return fd; diff --git a/mstarddc_spi.c b/mstarddc_spi.c index 5b9e40e0..ee5779c2 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -159,7 +159,7 @@ static int mstarddc_spi_init(const struct programmer_cfg *cfg) struct mstarddc_spi_data *mstarddc_data; // Get device, address from command-line - char *i2c_device = extract_programmer_param_str(NULL, "dev"); + char *i2c_device = extract_programmer_param_str(cfg, "dev"); if (i2c_device != NULL && strlen(i2c_device) > 0) { char *i2c_address = strchr(i2c_device, ':'); if (i2c_address != NULL) { @@ -182,7 +182,7 @@ static int mstarddc_spi_init(const struct programmer_cfg *cfg) msg_pinfo("Info: Will try to use device %s and address 0x%02x.\n", i2c_device, mstarddc_addr); // Get noreset=1 option from command-line - char *noreset = extract_programmer_param_str(NULL, "noreset"); + char *noreset = extract_programmer_param_str(cfg, "noreset"); if (noreset != NULL && noreset[0] == '1') mstarddc_doreset = 0; free(noreset); diff --git a/ni845x_spi.c b/ni845x_spi.c index 0096307b..3d74fd9e 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -553,7 +553,7 @@ static int ni845x_spi_init(const struct programmer_cfg *cfg) int32 tmp = 0; // read the cs parameter (which Chip select should we use) - CS_str = extract_programmer_param_str(NULL, "cs"); + CS_str = extract_programmer_param_str(cfg, "cs"); if (CS_str) { CS_number = CS_str[0] - '0'; free(CS_str); @@ -563,7 +563,7 @@ static int ni845x_spi_init(const struct programmer_cfg *cfg) } } - voltage = extract_programmer_param_str(NULL, "voltage"); + voltage = extract_programmer_param_str(cfg, "voltage"); if (voltage != NULL) { requested_io_voltage_mV = parse_voltage(voltage); free(voltage); @@ -571,9 +571,9 @@ static int ni845x_spi_init(const struct programmer_cfg *cfg) return 1; } - serial_number = extract_programmer_param_str(NULL, "serial"); + serial_number = extract_programmer_param_str(cfg, "serial"); - speed_str = extract_programmer_param_str(NULL, "spispeed"); + speed_str = extract_programmer_param_str(cfg, "spispeed"); if (speed_str) { spi_speed_KHz = strtoul(speed_str, &endptr, 0); if (*endptr) { @@ -586,7 +586,7 @@ static int ni845x_spi_init(const struct programmer_cfg *cfg) } ignore_io_voltage_limits = false; - ignore_io_voltage_limits_str = extract_programmer_param_str(NULL, "ignore_io_voltage_limits"); + ignore_io_voltage_limits_str = extract_programmer_param_str(cfg, "ignore_io_voltage_limits"); if (ignore_io_voltage_limits_str && strcmp(ignore_io_voltage_limits_str, "yes") == 0) { ignore_io_voltage_limits = true; diff --git a/ogp_spi.c b/ogp_spi.c index a994cb90..47a3d807 100644 --- a/ogp_spi.c +++ b/ogp_spi.c @@ -117,7 +117,7 @@ static int ogp_spi_init(const struct programmer_cfg *cfg) uint32_t ogp_reg__ce; uint32_t ogp_reg_sck; - type = extract_programmer_param_str(NULL, "rom"); + type = extract_programmer_param_str(cfg, "rom"); if (!type) { msg_perr("Please use flashrom -p ogp_spi:rom=... to specify " diff --git a/parade_lspcon.c b/parade_lspcon.c index a82cc315..761e46be 100644 --- a/parade_lspcon.c +++ b/parade_lspcon.c @@ -446,7 +446,7 @@ static int get_params(const struct programmer_cfg *cfg, bool *allow_brick) int ret = 0; *allow_brick = false; /* Default behaviour is to bail. */ - brick_str = extract_programmer_param_str(NULL, "allow_brick"); + brick_str = extract_programmer_param_str(cfg, "allow_brick"); if (brick_str) { if (!strcmp(brick_str, "yes")) { *allow_brick = true; @@ -479,7 +479,7 @@ static int parade_lspcon_init(const struct programmer_cfg *cfg) return SPI_GENERIC_ERROR; } - int fd = i2c_open_from_programmer_params(REGISTER_ADDRESS, 0); + int fd = i2c_open_from_programmer_params(cfg, REGISTER_ADDRESS, 0); if (fd < 0) return fd; diff --git a/pcidev.c b/pcidev.c index 2fbc1e53..72561f0e 100644 --- a/pcidev.c +++ b/pcidev.c @@ -272,7 +272,7 @@ struct pci_dev *pcidev_init(const struct dev_entry *devs, int bar) pci_filter_init(pacc, &filter); /* Filter by bb:dd.f (if supplied by the user). */ - pcidev_bdf = extract_programmer_param_str(NULL, "pci"); + pcidev_bdf = extract_programmer_param_str(NULL, "pci"); /* TODO(quasisec): pass prog_param */ if (pcidev_bdf != NULL) { if ((msg = pci_filter_parse_slot(&filter, pcidev_bdf))) { msg_perr("Error: %s\n", msg); diff --git a/pickit2_spi.c b/pickit2_spi.c index 312eaeae..b838234d 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -412,7 +412,7 @@ static int pickit2_spi_init(const struct programmer_cfg *cfg) int spispeed_idx = 0; char *param_str; - param_str = extract_programmer_param_str(NULL, "spispeed"); + param_str = extract_programmer_param_str(cfg, "spispeed"); if (param_str != NULL) { int i = 0; for (; spispeeds[i].name; i++) { @@ -430,7 +430,7 @@ static int pickit2_spi_init(const struct programmer_cfg *cfg) } int millivolt = 3500; - param_str = extract_programmer_param_str(NULL, "voltage"); + param_str = extract_programmer_param_str(cfg, "voltage"); if (param_str != NULL) { millivolt = parse_voltage(param_str); free(param_str); diff --git a/pony_spi.c b/pony_spi.c index 69be3aa0..04c3236e 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -130,7 +130,7 @@ static int get_params(const struct programmer_cfg *cfg, enum pony_type *type, in *have_device = 0; /* The parameter is in format "dev=/dev/device,type=serbang" */ - arg = extract_programmer_param_str(NULL, "dev"); + arg = extract_programmer_param_str(cfg, "dev"); if (arg && strlen(arg)) { sp_fd = sp_openserport(arg, 9600); if (sp_fd == SER_INV_FD) @@ -140,7 +140,7 @@ static int get_params(const struct programmer_cfg *cfg, enum pony_type *type, in } free(arg); - arg = extract_programmer_param_str(NULL, "type"); + arg = extract_programmer_param_str(cfg, "type"); if (arg && !strcasecmp(arg, "serbang")) { *type = TYPE_SERBANG; } else if (arg && !strcasecmp(arg, "si_prog")) { diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index d2eea6ad..2f073ae0 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1432,7 +1432,7 @@ static int configure_protocol(struct raiden_debug_spi_data *ctx_data) static int get_ap_request_type(const struct programmer_cfg *cfg) { int ap_request = RAIDEN_DEBUG_SPI_REQ_ENABLE_AP; - char *custom_rst_str = extract_programmer_param_str(NULL, "custom_rst"); + char *custom_rst_str = extract_programmer_param_str(cfg, "custom_rst"); if (custom_rst_str) { if (!strcasecmp(custom_rst_str, "true")) { ap_request = RAIDEN_DEBUG_SPI_REQ_ENABLE_AP_CUSTOM; @@ -1456,7 +1456,7 @@ static int get_target(const struct programmer_cfg *cfg) */ int request_enable = RAIDEN_DEBUG_SPI_REQ_ENABLE; - char *target_str = extract_programmer_param_str(NULL, "target"); + char *target_str = extract_programmer_param_str(cfg, "target"); if (target_str) { if (!strcasecmp(target_str, "ap")) request_enable = get_ap_request_type(cfg); @@ -1485,7 +1485,7 @@ static void free_dev_list(struct usb_device **dev_lst) static int raiden_debug_spi_init(const struct programmer_cfg *cfg) { struct usb_match match; - char *serial = extract_programmer_param_str(NULL, "serial"); + char *serial = extract_programmer_param_str(cfg, "serial"); struct usb_device *current; struct usb_device *device = NULL; int found = 0; diff --git a/rayer_spi.c b/rayer_spi.c index 95f7bbcf..3867cfc8 100644 --- a/rayer_spi.c +++ b/rayer_spi.c @@ -244,7 +244,7 @@ static int rayer_spi_init(const struct programmer_cfg *cfg) uint8_t lpt_outbyte; /* Non-default port requested? */ - arg = extract_programmer_param_str(NULL, "iobase"); + arg = extract_programmer_param_str(cfg, "iobase"); if (arg) { char *endptr = NULL; unsigned long tmp; @@ -277,7 +277,7 @@ static int rayer_spi_init(const struct programmer_cfg *cfg) msg_pdbg("Using address 0x%x as I/O base for parallel port access.\n", lpt_iobase); - arg = extract_programmer_param_str(NULL, "type"); + arg = extract_programmer_param_str(cfg, "type"); if (arg) { for (; prog->type != NULL; prog++) { if (strcasecmp(arg, prog->type) == 0) { diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index c4482acf..74458c8e 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -450,7 +450,7 @@ static int get_params(const struct programmer_cfg *cfg, bool *reset, bool *enter int ret = 0; *allow_brick = false; /* Default behaviour is to bail. */ - param_str = extract_programmer_param_str(NULL, "allow_brick"); + param_str = extract_programmer_param_str(cfg, "allow_brick"); if (param_str) { if (!strcmp(param_str, "yes")) { *allow_brick = true; @@ -462,7 +462,7 @@ static int get_params(const struct programmer_cfg *cfg, bool *reset, bool *enter free(param_str); *reset = false; /* Default behaviour is no MCU reset on tear-down. */ - param_str = extract_programmer_param_str(NULL, "reset_mcu"); + param_str = extract_programmer_param_str(cfg, "reset_mcu"); if (param_str) { if (param_str[0] == '1') { *reset = true; @@ -476,7 +476,7 @@ static int get_params(const struct programmer_cfg *cfg, bool *reset, bool *enter free(param_str); *enter_isp = true; /* Default behaviour is enter ISP on setup. */ - param_str = extract_programmer_param_str(NULL, "enter_isp"); + param_str = extract_programmer_param_str(cfg, "enter_isp"); if (param_str) { if (param_str[0] == '1') { *enter_isp = true; @@ -512,7 +512,7 @@ static int realtek_mst_i2c_spi_init(const struct programmer_cfg *cfg) return SPI_GENERIC_ERROR; } - int fd = i2c_open_from_programmer_params(REGISTER_ADDRESS, 0); + int fd = i2c_open_from_programmer_params(cfg, REGISTER_ADDRESS, 0); if (fd < 0) return fd; diff --git a/sb600spi.c b/sb600spi.c index b5d10bc3..40a6dbbf 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -416,7 +416,7 @@ static int handle_speed(const struct programmer_cfg *cfg, int16_t spireadmode_idx = -1; char *param_str; - param_str = extract_programmer_param_str(NULL, "spispeed"); + param_str = extract_programmer_param_str(cfg, "spispeed"); if (param_str != NULL) { unsigned int i; for (i = 0; i < ARRAY_SIZE(spispeeds); i++) { @@ -440,7 +440,7 @@ static int handle_speed(const struct programmer_cfg *cfg, free(param_str); } - param_str = extract_programmer_param_str(NULL, "spireadmode"); + param_str = extract_programmer_param_str(cfg, "spireadmode"); if (param_str != NULL) { unsigned int i; for (i = 0; i < ARRAY_SIZE(spireadmodes); i++) { @@ -529,7 +529,7 @@ static int handle_imc(const struct programmer_cfg *cfg, struct pci_dev *dev, enu return 0; bool amd_imc_force = false; - char *param_value = extract_programmer_param_str(NULL, "amd_imc_force"); + char *param_value = extract_programmer_param_str(cfg, "amd_imc_force"); if (param_value && !strcmp(param_value, "yes")) { amd_imc_force = true; msg_pspew("amd_imc_force enabled.\n"); diff --git a/serprog.c b/serprog.c index e0258930..c68449a7 100644 --- a/serprog.c +++ b/serprog.c @@ -574,7 +574,7 @@ static int serprog_init(const struct programmer_cfg *cfg) int have_device = 0; /* the parameter is either of format "dev=/dev/device[:baud]" or "ip=ip:port" */ - device = extract_programmer_param_str(NULL, "dev"); + device = extract_programmer_param_str(cfg, "dev"); if (device && strlen(device)) { char *baud_str = strstr(device, ":"); if (baud_str != NULL) { @@ -611,7 +611,7 @@ static int serprog_init(const struct programmer_cfg *cfg) } free(device); - device = extract_programmer_param_str(NULL, "ip"); + device = extract_programmer_param_str(cfg, "ip"); if (have_device && device) { msg_perr("Error: Both host and device specified.\n" "Please use either dev= or ip= but not both.\n"); @@ -739,7 +739,7 @@ static int serprog_init(const struct programmer_cfg *cfg) spi_master_serprog.max_data_read = v; msg_pdbg(MSGHEADER "Maximum read-n length is %d\n", v); } - spispeed = extract_programmer_param_str(NULL, "spispeed"); + spispeed = extract_programmer_param_str(cfg, "spispeed"); if (spispeed && strlen(spispeed)) { uint32_t f_spi_req, f_spi; uint8_t buf[4]; diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 07fdedd6..38fe9f95 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -490,7 +490,7 @@ static int stlinkv3_spi_init(const struct programmer_cfg *cfg) return 1; } - param_str = extract_programmer_param_str(NULL, "serial"); + param_str = extract_programmer_param_str(cfg, "serial"); if (param_str) msg_pdbg("Opening STLINK-V3 with serial: %s\n", param_str); @@ -515,7 +515,7 @@ static int stlinkv3_spi_init(const struct programmer_cfg *cfg) } free(param_str); - param_str = extract_programmer_param_str(NULL, "spispeed"); + param_str = extract_programmer_param_str(cfg, "spispeed"); if (param_str) { sck_freq_kHz = strtoul(param_str, &endptr, 0); if (*endptr || sck_freq_kHz == 0) { diff --git a/usb_device.c b/usb_device.c index 3869bbfc..f89e3bbb 100644 --- a/usb_device.c +++ b/usb_device.c @@ -31,7 +31,7 @@ static void usb_match_value_init(struct usb_match_value *match, char const *parameter) { - char *string = extract_programmer_param_str(NULL, parameter); + char *string = extract_programmer_param_str(NULL, parameter); /* TODO(quasisec): pass prog_param */ match->name = parameter; -- cgit v1.2.3