mail.coreboot.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
List overview
Download
flashrom-gerrit
September 2022
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
flashrom-gerrit@flashrom.org
1 participants
1244 discussions
Start a n
N
ew thread
[M] Change in flashrom[master]: chipset_enable.c: Change doit() and enable_flash_\S() signatures
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66672
) Change subject: chipset_enable.c: Change doit() and enable_flash_\S() signatures ...................................................................... chipset_enable.c: Change doit() and enable_flash_\S() signatures Ran; ``` $ sed -Ei 's/int enable_flash_(\S+)\(/int enable_flash_\1(const char *prog_param, /g' chipset_enable.c $ sed -Ei 's/return enable_flash_(\S+)\(/return enable_flash_\1(cfg, /g' chipset_enable.c ``` and dealt with special cases manually. Change-Id: I62c5d49a83ed4afb86ac3f0fae56defa1338ab4f Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66672
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> --- M chipset_enable.c M include/programmer.h 2 files changed, 132 insertions(+), 112 deletions(-) Approvals: build bot (Jenkins): Verified Anastasia Klimchuk: Looks good to me, approved diff --git a/chipset_enable.c b/chipset_enable.c index e57493f..3d7c49f 100644 --- a/chipset_enable.c +++ b/chipset_enable.c @@ -43,7 +43,7 @@ #include "hwaccess_x86_io.h" #include "hwaccess_x86_msr.h" -static int enable_flash_ali_m1533(struct pci_dev *dev, const char *name) +static int enable_flash_ali_m1533(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t tmp; @@ -58,7 +58,7 @@ return 0; } -static int enable_flash_rdc_r8610(struct pci_dev *dev, const char *name) +static int enable_flash_rdc_r8610(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t tmp; @@ -84,7 +84,7 @@ return 0; } -static int enable_flash_sis85c496(struct pci_dev *dev, const char *name) +static int enable_flash_sis85c496(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t tmp; @@ -95,7 +95,7 @@ return 0; } -static int enable_flash_sis_mapping(struct pci_dev *dev, const char *name) +static int enable_flash_sis_mapping(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { #define SIS_MAPREG 0x40 uint8_t new, newer; @@ -134,7 +134,7 @@ return sbdev; } -static int enable_flash_sis501(struct pci_dev *dev, const char *name) +static int enable_flash_sis501(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t tmp; int ret = 0; @@ -144,7 +144,7 @@ if (!sbdev) return -1; - ret = enable_flash_sis_mapping(sbdev, name); + ret = enable_flash_sis_mapping(cfg, sbdev, name); tmp = sio_read(0x22, 0x80); tmp &= (~0x20); @@ -159,7 +159,7 @@ return ret; } -static int enable_flash_sis5511(struct pci_dev *dev, const char *name) +static int enable_flash_sis5511(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t tmp; int ret = 0; @@ -169,7 +169,7 @@ if (!sbdev) return -1; - ret = enable_flash_sis_mapping(sbdev, name); + ret = enable_flash_sis_mapping(cfg, sbdev, name); tmp = sio_read(0x22, 0x50); tmp &= (~0x20); @@ -179,7 +179,7 @@ return ret; } -static int enable_flash_sis5x0(struct pci_dev *dev, const char *name, uint8_t dis_mask, uint8_t en_mask) +static int enable_flash_sis5x0(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name, uint8_t dis_mask, uint8_t en_mask) { #define SIS_REG 0x45 uint8_t new, newer; @@ -190,7 +190,7 @@ if (!sbdev) return -1; - ret = enable_flash_sis_mapping(sbdev, name); + ret = enable_flash_sis_mapping(cfg, sbdev, name); new = pci_read_byte(sbdev, SIS_REG); new &= (~dis_mask); @@ -206,14 +206,14 @@ return ret; } -static int enable_flash_sis530(struct pci_dev *dev, const char *name) +static int enable_flash_sis530(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_sis5x0(dev, name, 0x20, 0x04); + return enable_flash_sis5x0(cfg, dev, name, 0x20, 0x04); } -static int enable_flash_sis540(struct pci_dev *dev, const char *name) +static int enable_flash_sis540(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_sis5x0(dev, name, 0x80, 0x40); + return enable_flash_sis5x0(cfg, dev, name, 0x80, 0x40); } /* Datasheet: @@ -222,7 +222,7 @@ * - PDF:
http://www.intel.com/design/intarch/datashts/29056201.pdf
* - Order Number: 290562-001 */ -static int enable_flash_piix4(struct pci_dev *dev, const char *name) +static int enable_flash_piix4(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint16_t old, new; uint16_t xbcs = 0x4e; /* X-Bus Chip Select register. */ @@ -379,7 +379,7 @@ return enable_flash_ich_bios_cntl_common(ich_generation, addr, NULL, 0); } -static int enable_flash_ich_fwh_decode(struct pci_dev *dev, enum ich_chipset ich_generation) +static int enable_flash_ich_fwh_decode(const struct programmer_cfg *cfg, struct pci_dev *dev, enum ich_chipset ich_generation) { uint8_t fwh_sel1 = 0, fwh_sel2 = 0, fwh_dec_en_lo = 0, fwh_dec_en_hi = 0; /* silence compilers */ bool implemented = 0; @@ -554,36 +554,36 @@ return 0; } -static int enable_flash_ich_fwh(struct pci_dev *dev, enum ich_chipset ich_generation, uint8_t bios_cntl) +static int enable_flash_ich_fwh(const struct programmer_cfg *cfg, struct pci_dev *dev, enum ich_chipset ich_generation, uint8_t bios_cntl) { int err; /* Configure FWH IDSEL decoder maps. */ - if ((err = enable_flash_ich_fwh_decode(dev, ich_generation)) != 0) + if ((err = enable_flash_ich_fwh_decode(cfg, dev, ich_generation)) != 0) return err; internal_buses_supported &= BUS_FWH; return enable_flash_ich_bios_cntl_config_space(dev, ich_generation, bios_cntl); } -static int enable_flash_ich0(struct pci_dev *dev, const char *name) +static int enable_flash_ich0(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_fwh(dev, CHIPSET_ICH, 0x4e); + return enable_flash_ich_fwh(cfg, dev, CHIPSET_ICH, 0x4e); } -static int enable_flash_ich2345(struct pci_dev *dev, const char *name) +static int enable_flash_ich2345(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_fwh(dev, CHIPSET_ICH2345, 0x4e); + return enable_flash_ich_fwh(cfg, dev, CHIPSET_ICH2345, 0x4e); } -static int enable_flash_ich6(struct pci_dev *dev, const char *name) +static int enable_flash_ich6(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_fwh(dev, CHIPSET_ICH6, 0xdc); + return enable_flash_ich_fwh(cfg, dev, CHIPSET_ICH6, 0xdc); } -static int enable_flash_poulsbo(struct pci_dev *dev, const char *name) +static int enable_flash_poulsbo(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_fwh(dev, CHIPSET_POULSBO, 0xd8); + return enable_flash_ich_fwh(cfg, dev, CHIPSET_POULSBO, 0xd8); } static enum chipbustype enable_flash_ich_report_gcs( @@ -769,7 +769,7 @@ return boot_straps[bbs].bus; } -static int enable_flash_ich_spi(struct pci_dev *dev, enum ich_chipset ich_generation, uint8_t bios_cntl) +static int enable_flash_ich_spi(const struct programmer_cfg *cfg, struct pci_dev *dev, enum ich_chipset ich_generation, uint8_t bios_cntl) { /* Get physical address of Root Complex Register Block */ uint32_t rcra = pci_read_long(dev, 0xf0) & 0xffffc000; @@ -783,7 +783,7 @@ const enum chipbustype boot_buses = enable_flash_ich_report_gcs(dev, ich_generation, rcrb); /* Handle FWH-related parameters and initialization */ - int ret_fwh = enable_flash_ich_fwh(dev, ich_generation, bios_cntl); + int ret_fwh = enable_flash_ich_fwh(cfg, dev, ich_generation, bios_cntl); if (ret_fwh == ERROR_FATAL) return ret_fwh; @@ -830,82 +830,82 @@ return 0; } -static int enable_flash_tunnelcreek(struct pci_dev *dev, const char *name) +static int enable_flash_tunnelcreek(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_TUNNEL_CREEK, 0xd8); + return enable_flash_ich_spi(cfg, dev, CHIPSET_TUNNEL_CREEK, 0xd8); } -static int enable_flash_s12x0(struct pci_dev *dev, const char *name) +static int enable_flash_s12x0(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_CENTERTON, 0xd8); + return enable_flash_ich_spi(cfg, dev, CHIPSET_CENTERTON, 0xd8); } -static int enable_flash_ich7(struct pci_dev *dev, const char *name) +static int enable_flash_ich7(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_ICH7, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_ICH7, 0xdc); } -static int enable_flash_ich8(struct pci_dev *dev, const char *name) +static int enable_flash_ich8(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_ICH8, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_ICH8, 0xdc); } -static int enable_flash_ich9(struct pci_dev *dev, const char *name) +static int enable_flash_ich9(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_ICH9, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_ICH9, 0xdc); } -static int enable_flash_ich10(struct pci_dev *dev, const char *name) +static int enable_flash_ich10(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_ICH10, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_ICH10, 0xdc); } /* Ibex Peak aka. 5 series & 3400 series */ -static int enable_flash_pch5(struct pci_dev *dev, const char *name) +static int enable_flash_pch5(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_5_SERIES_IBEX_PEAK, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_5_SERIES_IBEX_PEAK, 0xdc); } /* Cougar Point aka. 6 series & c200 series */ -static int enable_flash_pch6(struct pci_dev *dev, const char *name) +static int enable_flash_pch6(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_6_SERIES_COUGAR_POINT, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_6_SERIES_COUGAR_POINT, 0xdc); } /* Panther Point aka. 7 series */ -static int enable_flash_pch7(struct pci_dev *dev, const char *name) +static int enable_flash_pch7(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_7_SERIES_PANTHER_POINT, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_7_SERIES_PANTHER_POINT, 0xdc); } /* Lynx Point aka. 8 series */ -static int enable_flash_pch8(struct pci_dev *dev, const char *name) +static int enable_flash_pch8(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_8_SERIES_LYNX_POINT, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_8_SERIES_LYNX_POINT, 0xdc); } /* Lynx Point LP aka. 8 series low-power */ -static int enable_flash_pch8_lp(struct pci_dev *dev, const char *name) +static int enable_flash_pch8_lp(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_8_SERIES_LYNX_POINT_LP, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_8_SERIES_LYNX_POINT_LP, 0xdc); } /* Wellsburg (for Haswell-EP Xeons) */ -static int enable_flash_pch8_wb(struct pci_dev *dev, const char *name) +static int enable_flash_pch8_wb(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_8_SERIES_WELLSBURG, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_8_SERIES_WELLSBURG, 0xdc); } /* Wildcat Point */ -static int enable_flash_pch9(struct pci_dev *dev, const char *name) +static int enable_flash_pch9(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_9_SERIES_WILDCAT_POINT, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_9_SERIES_WILDCAT_POINT, 0xdc); } /* Wildcat Point LP */ -static int enable_flash_pch9_lp(struct pci_dev *dev, const char *name) +static int enable_flash_pch9_lp(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { - return enable_flash_ich_spi(dev, CHIPSET_9_SERIES_WILDCAT_POINT_LP, 0xdc); + return enable_flash_ich_spi(cfg, dev, CHIPSET_9_SERIES_WILDCAT_POINT_LP, 0xdc); } /* Sunrise Point */ @@ -915,7 +915,7 @@ return 0; } -static int enable_flash_pch100_or_c620( +static int enable_flash_pch100_or_c620(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name, const int slot, const int func, const enum ich_chipset pch_generation) { @@ -978,59 +978,59 @@ return ret; } -static int enable_flash_pch100(struct pci_dev *const dev, const char *const name) +static int enable_flash_pch100(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_100_SERIES_SUNRISE_POINT); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_100_SERIES_SUNRISE_POINT); } -static int enable_flash_c620(struct pci_dev *const dev, const char *const name) +static int enable_flash_c620(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_C620_SERIES_LEWISBURG); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_C620_SERIES_LEWISBURG); } -static int enable_flash_pch300(struct pci_dev *const dev, const char *const name) +static int enable_flash_pch300(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_300_SERIES_CANNON_POINT); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_300_SERIES_CANNON_POINT); } -static int enable_flash_pch400(struct pci_dev *const dev, const char *const name) +static int enable_flash_pch400(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_400_SERIES_COMET_POINT); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_400_SERIES_COMET_POINT); } -static int enable_flash_pch500(struct pci_dev *const dev, const char *const name) +static int enable_flash_pch500(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_500_SERIES_TIGER_POINT); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_500_SERIES_TIGER_POINT); } -static int enable_flash_pch600(struct pci_dev *const dev, const char *const name) +static int enable_flash_pch600(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_600_SERIES_ALDER_POINT); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_600_SERIES_ALDER_POINT); } -static int enable_flash_mtl(struct pci_dev *const dev, const char *const name) +static int enable_flash_mtl(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_METEOR_LAKE); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_METEOR_LAKE); } -static int enable_flash_mcc(struct pci_dev *const dev, const char *const name) +static int enable_flash_mcc(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_ELKHART_LAKE); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_ELKHART_LAKE); } -static int enable_flash_jsl(struct pci_dev *const dev, const char *const name) +static int enable_flash_jsl(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x1f, 5, CHIPSET_JASPER_LAKE); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x1f, 5, CHIPSET_JASPER_LAKE); } -static int enable_flash_apl(struct pci_dev *const dev, const char *const name) +static int enable_flash_apl(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x0d, 2, CHIPSET_APOLLO_LAKE); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x0d, 2, CHIPSET_APOLLO_LAKE); } -static int enable_flash_glk(struct pci_dev *const dev, const char *const name) +static int enable_flash_glk(const struct programmer_cfg *cfg, struct pci_dev *const dev, const char *const name) { - return enable_flash_pch100_or_c620(dev, name, 0x0d, 2, CHIPSET_GEMINI_LAKE); + return enable_flash_pch100_or_c620(cfg, dev, name, 0x0d, 2, CHIPSET_GEMINI_LAKE); } /* Silvermont architecture: Bay Trail(-T/-I), Avoton/Rangeley. @@ -1043,7 +1043,7 @@ * - SPIBAR (coined SBASE) at LPC config 0x54 (instead of [RCRB] + 0x3800). * - BIOS_CNTL (coined BCR) at [SPIBAR] + 0xFC (instead of LPC config 0xDC). */ -static int enable_flash_silvermont(struct pci_dev *dev, const char *name) +static int enable_flash_silvermont(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { enum ich_chipset ich_generation = CHIPSET_BAYTRAIL; @@ -1059,7 +1059,7 @@ physunmap(rcrb, 4); /* Handle fwh_idsel parameter */ - int ret_fwh = enable_flash_ich_fwh_decode(dev, ich_generation); + int ret_fwh = enable_flash_ich_fwh_decode(cfg, dev, ich_generation); if (ret_fwh == ERROR_FATAL) return ret_fwh; @@ -1091,7 +1091,7 @@ return 0; } -static int via_no_byte_merge(struct pci_dev *dev, const char *name) +static int via_no_byte_merge(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t val; @@ -1104,7 +1104,7 @@ return NOT_DONE_YET; /* need to find south bridge, too */ } -static int enable_flash_vt823x(struct pci_dev *dev, const char *name) +static int enable_flash_vt823x(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t val; @@ -1131,7 +1131,7 @@ return 0; } -static int enable_flash_vt_vx(struct pci_dev *dev, const char *name) +static int enable_flash_vt_vx(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { struct pci_dev *south_north = pcidev_find(0x1106, 0xa353); if (south_north == NULL) { @@ -1142,7 +1142,7 @@ msg_pdbg("Strapped to "); if ((pci_read_byte(south_north, 0x56) & 0x01) == 0) { msg_pdbg("LPC.\n"); - return enable_flash_vt823x(dev, name); + return enable_flash_vt823x(cfg, dev, name); } msg_pdbg("SPI.\n"); @@ -1195,12 +1195,12 @@ return via_init_spi(spi0_mm_base); } -static int enable_flash_vt8237s_spi(struct pci_dev *dev, const char *name) +static int enable_flash_vt8237s_spi(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { return via_init_spi(pci_read_long(dev, 0xbc) << 8); } -static int enable_flash_cs5530(struct pci_dev *dev, const char *name) +static int enable_flash_cs5530(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t reg8; @@ -1264,7 +1264,7 @@ * To enable write to NOR Boot flash for the benefit of systems that have such * a setup, raise MSR 0x51400018 WE_CS3 (write enable Boot Flash Chip Select). */ -static int enable_flash_cs5536(struct pci_dev *dev, const char *name) +static int enable_flash_cs5536(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { #define MSR_RCONF_DEFAULT 0x1808 #define MSR_NORF_CTL 0x51400018 @@ -1293,7 +1293,7 @@ return 0; } -static int enable_flash_sc1100(struct pci_dev *dev, const char *name) +static int enable_flash_sc1100(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { #define SC_REG 0x52 uint8_t new; @@ -1318,7 +1318,7 @@ * 6 FFB0_0000h–FFBF_FFFFh <- FFF80000h-FFFDFFFFh <- <- * 5 00E8... <- <- FFF00000h-FFF7FFFFh <- */ -static int enable_flash_amd_via(struct pci_dev *dev, const char *name, uint8_t decode_val) +static int enable_flash_amd_via(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name, uint8_t decode_val) { #define AMD_MAPREG 0x43 #define AMD_ENREG 0x40 @@ -1352,29 +1352,29 @@ return 0; } -static int enable_flash_amd_768_8111(struct pci_dev *dev, const char *name) +static int enable_flash_amd_768_8111(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { /* Enable decoding of 0xFFB00000 to 0xFFFFFFFF (5 MB). */ max_rom_decode.lpc = 5 * 1024 * 1024; - return enable_flash_amd_via(dev, name, 0xC0); + return enable_flash_amd_via(cfg, dev, name, 0xC0); } -static int enable_flash_vt82c586(struct pci_dev *dev, const char *name) +static int enable_flash_vt82c586(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { /* Enable decoding of 0xFFF80000 to 0xFFFFFFFF. (512 kB) */ max_rom_decode.parallel = 512 * 1024; - return enable_flash_amd_via(dev, name, 0xC0); + return enable_flash_amd_via(cfg, dev, name, 0xC0); } /* Works for VT82C686A/B too. */ -static int enable_flash_vt82c596(struct pci_dev *dev, const char *name) +static int enable_flash_vt82c596(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { /* Enable decoding of 0xFFF00000 to 0xFFFFFFFF. (1 MB) */ max_rom_decode.parallel = 1024 * 1024; - return enable_flash_amd_via(dev, name, 0xE0); + return enable_flash_amd_via(cfg, dev, name, 0xE0); } -static int enable_flash_sb600(struct pci_dev *dev, const char *name) +static int enable_flash_sb600(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint32_t prot; uint8_t reg; @@ -1448,7 +1448,7 @@ } /* sets bit 0 in 0x6d */ -static int enable_flash_nvidia_common(struct pci_dev *dev, const char *name) +static int enable_flash_nvidia_common(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t old, new; @@ -1465,16 +1465,16 @@ return 0; } -static int enable_flash_nvidia_nforce2(struct pci_dev *dev, const char *name) +static int enable_flash_nvidia_nforce2(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { rpci_write_byte(dev, 0x92, 0); - if (enable_flash_nvidia_common(dev, name)) + if (enable_flash_nvidia_common(cfg, dev, name)) return ERROR_NONFATAL; else return 0; } -static int enable_flash_ck804(struct pci_dev *dev, const char *name) +static int enable_flash_ck804(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint32_t segctrl; uint8_t reg, old, new; @@ -1540,7 +1540,7 @@ } } - if (enable_flash_nvidia_common(dev, name)) + if (enable_flash_nvidia_common(cfg, dev, name)) err++; if (err > 0) @@ -1549,7 +1549,7 @@ return 0; } -static int enable_flash_osb4(struct pci_dev *dev, const char *name) +static int enable_flash_osb4(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t tmp; @@ -1567,7 +1567,7 @@ } /* ATI Technologies Inc IXP SB400 PCI-ISA Bridge (rev 80) */ -static int enable_flash_sb400(struct pci_dev *dev, const char *name) +static int enable_flash_sb400(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t tmp; struct pci_dev *smbusdev; @@ -1602,7 +1602,7 @@ return 0; } -static int enable_flash_mcp55(struct pci_dev *dev, const char *name) +static int enable_flash_mcp55(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t val; uint16_t wordval; @@ -1618,7 +1618,7 @@ wordval |= 0x7fff; /* 16M */ rpci_write_word(dev, 0x90, wordval); - if (enable_flash_nvidia_common(dev, name)) + if (enable_flash_nvidia_common(cfg, dev, name)) return ERROR_NONFATAL; else return 0; @@ -1629,7 +1629,7 @@ * It is assumed that LPC chips need the MCP55 code and SPI chips need the * code provided in enable_flash_mcp6x_7x_common. */ -static int enable_flash_mcp6x_7x(struct pci_dev *dev, const char *name) +static int enable_flash_mcp6x_7x(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { int ret = 0, want_spi = 0; uint8_t val; @@ -1641,7 +1641,7 @@ switch ((val >> 5) & 0x3) { case 0x0: - ret = enable_flash_mcp55(dev, name); + ret = enable_flash_mcp55(cfg, dev, name); internal_buses_supported &= BUS_LPC; msg_pdbg("Flash bus type is LPC\n"); break; @@ -1680,7 +1680,7 @@ return ret; } -static int enable_flash_ht1000(struct pci_dev *dev, const char *name) +static int enable_flash_ht1000(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { uint8_t val; @@ -1703,7 +1703,7 @@ * complete flash is mapped somewhere below 1G. The position can be determined * by the BOOTCS PAR register. */ -static int get_flashbase_sc520(struct pci_dev *dev, const char *name) +static int get_flashbase_sc520(const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name) { int i, bootcs_found = 0; uint32_t parx = 0; @@ -2231,7 +2231,7 @@ continue; } msg_pinfo("Enabling flash write... "); - ret = chipset_enables[i].doit(dev, chipset_enables[i].device_name); + ret = chipset_enables[i].doit(NULL, dev, chipset_enables[i].device_name); if (ret == NOT_DONE_YET) { ret = -2; msg_pinfo("OK - searching further chips.\n"); diff --git a/include/programmer.h b/include/programmer.h index 76da9f9..9aba60f 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -150,7 +150,7 @@ const enum test_state status; const char *vendor_name; const char *device_name; - int (*doit) (struct pci_dev *dev, const char *name); + int (*doit) (const struct programmer_cfg *cfg, struct pci_dev *dev, const char *name); }; extern const struct penable chipset_enables[]; -- To view, visit
https://review.coreboot.org/c/flashrom/+/66672
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I62c5d49a83ed4afb86ac3f0fae56defa1338ab4f Gerrit-Change-Number: 66672 Gerrit-PatchSet: 10 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-CC: Felix Singer <felixsinger(a)posteo.net> Gerrit-MessageType: merged
1
0
0
0
[M] Change in flashrom[master]: tree: Fix drivers to pass programmer_cfg to pcidev_init()
by Edward O'Callaghan (Code Review)
07 Sep '22
07 Sep '22
Edward O'Callaghan has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66671
) ( 9 is the latest approved patch-set. No files were changed between the latest approved patch-set and the submitted one. )Change subject: tree: Fix drivers to pass programmer_cfg to pcidev_init() ...................................................................... tree: Fix drivers to pass programmer_cfg to pcidev_init() Allow for programmer_cfg plumbing in pcidev.c The pci drivers impacted are plumbed here as well. Change-Id: Ie0c9d1c0866d44f64d037c596f2e30547fcfd58f Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66671
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> --- M atahpt.c M atapromise.c M atavia.c M drkaiser.c M gfxnvidia.c M include/programmer.h M it8212.c M nic3com.c M nicintel.c M nicintel_eeprom.c M nicintel_spi.c M nicnatsemi.c M nicrealtek.c M ogp_spi.c M pcidev.c M satamv.c M satasii.c M tests/tests.c M tests/wraps.h 19 files changed, 39 insertions(+), 20 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/atahpt.c b/atahpt.c index 2ab51a8..5c636d1 100644 --- a/atahpt.c +++ b/atahpt.c @@ -92,7 +92,7 @@ if (rget_io_perms()) return 1; - dev = pcidev_init(ata_hpt, PCI_BASE_ADDRESS_4); + dev = pcidev_init(cfg, ata_hpt, PCI_BASE_ADDRESS_4); if (!dev) return 1; diff --git a/atapromise.c b/atapromise.c index 4be2f71..63463f5 100644 --- a/atapromise.c +++ b/atapromise.c @@ -140,7 +140,7 @@ if (rget_io_perms()) return 1; - dev = pcidev_init(ata_promise, PCI_BASE_ADDRESS_4); + dev = pcidev_init(cfg, ata_promise, PCI_BASE_ADDRESS_4); if (!dev) return 1; diff --git a/atavia.c b/atavia.c index 6e64bb4..51530a4 100644 --- a/atavia.c +++ b/atavia.c @@ -163,7 +163,7 @@ } free(arg); - dev = pcidev_init(ata_via, PCI_ROM_ADDRESS); /* Actually no BAR setup needed at all. */ + dev = pcidev_init(cfg, ata_via, PCI_ROM_ADDRESS); /* Actually no BAR setup needed at all. */ if (!dev) return 1; diff --git a/drkaiser.c b/drkaiser.c index 2fb6b91..b121eec 100644 --- a/drkaiser.c +++ b/drkaiser.c @@ -87,7 +87,7 @@ uint32_t addr; uint8_t *bar; - dev = pcidev_init(drkaiser_pcidev, PCI_BASE_ADDRESS_2); + dev = pcidev_init(cfg, drkaiser_pcidev, PCI_BASE_ADDRESS_2); if (!dev) return 1; diff --git a/gfxnvidia.c b/gfxnvidia.c index 19fa2b6..941f0e8 100644 --- a/gfxnvidia.c +++ b/gfxnvidia.c @@ -111,7 +111,7 @@ uint32_t reg32; uint8_t *bar; - dev = pcidev_init(gfx_nvidia, PCI_BASE_ADDRESS_0); + dev = pcidev_init(cfg, gfx_nvidia, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/include/programmer.h b/include/programmer.h index 4ed68da..76da9f9 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -124,7 +124,7 @@ extern struct pci_access *pacc; int pci_init_common(void); uintptr_t pcidev_readbar(struct pci_dev *dev, int bar); -struct pci_dev *pcidev_init(const struct dev_entry *devs, int bar); +struct pci_dev *pcidev_init(const struct programmer_cfg *cfg, const struct dev_entry *devs, int bar); struct pci_dev *pcidev_scandev(struct pci_filter *filter, struct pci_dev *start); struct pci_dev *pcidev_getdevfn(struct pci_dev *dev, const int func); struct pci_dev *pcidev_find_vendorclass(uint16_t vendor, uint16_t devclass); diff --git a/it8212.c b/it8212.c index 4d73665..18d1173 100644 --- a/it8212.c +++ b/it8212.c @@ -78,7 +78,7 @@ { uint8_t *bar; - struct pci_dev *dev = pcidev_init(devs_it8212, PCI_ROM_ADDRESS); + struct pci_dev *dev = pcidev_init(cfg, devs_it8212, PCI_ROM_ADDRESS); if (!dev) return 1; diff --git a/nic3com.c b/nic3com.c index fd4fe2b..44710ed 100644 --- a/nic3com.c +++ b/nic3com.c @@ -111,7 +111,7 @@ if (rget_io_perms()) return 1; - dev = pcidev_init(nics_3com, PCI_BASE_ADDRESS_0); + dev = pcidev_init(cfg, nics_3com, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/nicintel.c b/nicintel.c index 9ef0315..16cb5e4 100644 --- a/nicintel.c +++ b/nicintel.c @@ -85,7 +85,7 @@ uint8_t *control_bar; /* FIXME: BAR2 is not available if the device uses the CardBus function. */ - dev = pcidev_init(nics_intel, PCI_BASE_ADDRESS_2); + dev = pcidev_init(cfg, nics_intel, PCI_BASE_ADDRESS_2); if (!dev) return 1; diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c index 8e59a45..4d3e7d5 100644 --- a/nicintel_eeprom.c +++ b/nicintel_eeprom.c @@ -485,7 +485,7 @@ uint32_t eec = 0; uint8_t *eebar; - struct pci_dev *dev = pcidev_init(nics_intel_ee, PCI_BASE_ADDRESS_0); + struct pci_dev *dev = pcidev_init(cfg, nics_intel_ee, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/nicintel_spi.c b/nicintel_spi.c index 74cb122..851b525 100644 --- a/nicintel_spi.c +++ b/nicintel_spi.c @@ -289,7 +289,7 @@ { struct pci_dev *dev = NULL; - dev = pcidev_init(nics_intel_spi, PCI_BASE_ADDRESS_0); + dev = pcidev_init(cfg, nics_intel_spi, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/nicnatsemi.c b/nicnatsemi.c index b9c58bc..779fb33 100644 --- a/nicnatsemi.c +++ b/nicnatsemi.c @@ -96,7 +96,7 @@ if (rget_io_perms()) return 1; - dev = pcidev_init(nics_natsemi, PCI_BASE_ADDRESS_0); + dev = pcidev_init(cfg, nics_natsemi, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/nicrealtek.c b/nicrealtek.c index 61eb38b..7bf1ac9 100644 --- a/nicrealtek.c +++ b/nicrealtek.c @@ -107,7 +107,7 @@ if (rget_io_perms()) return 1; - dev = pcidev_init(nics_realtek, PCI_BASE_ADDRESS_0); + dev = pcidev_init(cfg, nics_realtek, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/ogp_spi.c b/ogp_spi.c index 47a3d80..94915a3 100644 --- a/ogp_spi.c +++ b/ogp_spi.c @@ -140,7 +140,7 @@ } free(type); - dev = pcidev_init(ogp_spi, PCI_BASE_ADDRESS_0); + dev = pcidev_init(cfg, ogp_spi, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/pcidev.c b/pcidev.c index 72561f0..0b35944 100644 --- a/pcidev.c +++ b/pcidev.c @@ -257,7 +257,7 @@ * also matches the specified bus:device.function. * For convenience, this function also registers its own undo handlers. */ -struct pci_dev *pcidev_init(const struct dev_entry *devs, int bar) +struct pci_dev *pcidev_init(const struct programmer_cfg *cfg, const struct dev_entry *devs, int bar) { struct pci_dev *dev; struct pci_dev *found_dev = NULL; @@ -272,7 +272,7 @@ pci_filter_init(pacc, &filter); /* Filter by bb:dd.f (if supplied by the user). */ - pcidev_bdf = extract_programmer_param_str(NULL, "pci"); /* TODO(quasisec): pass prog_param */ + pcidev_bdf = extract_programmer_param_str(cfg, "pci"); if (pcidev_bdf != NULL) { if ((msg = pci_filter_parse_slot(&filter, pcidev_bdf))) { msg_perr("Error: %s\n", msg); diff --git a/satamv.c b/satamv.c index 19ecf22..f886076 100644 --- a/satamv.c +++ b/satamv.c @@ -126,7 +126,7 @@ return 1; /* BAR0 has all internal registers memory mapped. */ - dev = pcidev_init(satas_mv, PCI_BASE_ADDRESS_0); + dev = pcidev_init(cfg, satas_mv, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/satasii.c b/satasii.c index a56171b..44b7331 100644 --- a/satasii.c +++ b/satasii.c @@ -112,7 +112,7 @@ uint16_t reg_offset, id; uint8_t *bar; - dev = pcidev_init(satas_sii, PCI_BASE_ADDRESS_0); + dev = pcidev_init(cfg, satas_sii, PCI_BASE_ADDRESS_0); if (!dev) return 1; diff --git a/tests/tests.c b/tests/tests.c index 11348b5..7a448d4 100644 --- a/tests/tests.c +++ b/tests/tests.c @@ -52,7 +52,7 @@ .device_id = NON_ZERO, }; -struct pci_dev *__wrap_pcidev_init(void *devs, int bar) +struct pci_dev *__wrap_pcidev_init(const struct programmer_cfg *cfg, void *devs, int bar) { LOG_ME; return &mock_pci_dev; diff --git a/tests/wraps.h b/tests/wraps.h index bfa8a41..f97eaba 100644 --- a/tests/wraps.h +++ b/tests/wraps.h @@ -19,10 +19,12 @@ #include <stdio.h> #include "flash.h" +struct programmer_cfg; /* defined in programmer.h */ + char *__wrap_strdup(const char *s); void __wrap_physunmap(void *virt_addr, size_t len); void *__wrap_physmap(const char *descr, uintptr_t phys_addr, size_t len); -struct pci_dev *__wrap_pcidev_init(void *devs, int bar); +struct pci_dev *__wrap_pcidev_init(const struct programmer_cfg *cfg, void *devs, int bar); uintptr_t __wrap_pcidev_readbar(void *dev, int bar); void __wrap_sio_write(uint16_t port, uint8_t reg, uint8_t data); uint8_t __wrap_sio_read(uint16_t port, uint8_t reg); -- To view, visit
https://review.coreboot.org/c/flashrom/+/66671
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: Ie0c9d1c0866d44f64d037c596f2e30547fcfd58f Gerrit-Change-Number: 66671 Gerrit-PatchSet: 11 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-MessageType: merged
1
0
0
0
[M] Change in flashrom[master]: usb_device.c: Allow for programmer_cfg plumbing
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66670
) Change subject: usb_device.c: Allow for programmer_cfg plumbing ...................................................................... usb_device.c: Allow for programmer_cfg plumbing The only driver impacted is raiden_debug_spi.c and so plumb state directly. Change-Id: I85ff3117de8743b0a548dad98875cc41f48cac93 Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66670
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> --- M include/usb_device.h M raiden_debug_spi.c M usb_device.c 3 files changed, 35 insertions(+), 17 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/include/usb_device.h b/include/usb_device.h index 282a755..ed8187b 100644 --- a/include/usb_device.h +++ b/include/usb_device.h @@ -102,7 +102,7 @@ * extract_programmer_param_str. If the value is found convert it to an integer * using strtol, accepting hex, decimal and octal encoding. */ -void usb_match_init(struct usb_match *match); +void usb_match_init(const struct programmer_cfg *cfg, struct usb_match *match); /* * Add a default value to a usb_match_value. This must be done after calling diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index 2f073ae..161471c 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1497,7 +1497,7 @@ return 1; } - usb_match_init(&match); + usb_match_init(cfg, &match); usb_match_value_default(&match.vid, GOOGLE_VID); usb_match_value_default(&match.class, LIBUSB_CLASS_VENDOR_SPEC); diff --git a/usb_device.c b/usb_device.c index f89e3bb..b23b204 100644 --- a/usb_device.c +++ b/usb_device.c @@ -28,10 +28,11 @@ * Possibly extract a programmer parameter and use it to initialize the given * match value structure. */ -static void usb_match_value_init(struct usb_match_value *match, +static void usb_match_value_init(const struct programmer_cfg *cfg, + struct usb_match_value *match, char const *parameter) { - char *string = extract_programmer_param_str(NULL, parameter); /* TODO(quasisec): pass prog_param */ + char *string = extract_programmer_param_str(cfg, parameter); match->name = parameter; @@ -45,21 +46,21 @@ free(string); } -#define USB_MATCH_VALUE_INIT(NAME) \ - usb_match_value_init(&match->NAME, #NAME) +#define USB_MATCH_VALUE_INIT(PPARAM, NAME) \ + usb_match_value_init(PPARAM, &match->NAME, #NAME) -void usb_match_init(struct usb_match *match) +void usb_match_init(const struct programmer_cfg *cfg, struct usb_match *match) { - USB_MATCH_VALUE_INIT(vid); - USB_MATCH_VALUE_INIT(pid); - USB_MATCH_VALUE_INIT(bus); - USB_MATCH_VALUE_INIT(address); - USB_MATCH_VALUE_INIT(config); - USB_MATCH_VALUE_INIT(interface); - USB_MATCH_VALUE_INIT(altsetting); - USB_MATCH_VALUE_INIT(class); - USB_MATCH_VALUE_INIT(subclass); - USB_MATCH_VALUE_INIT(protocol); + USB_MATCH_VALUE_INIT(cfg, vid); + USB_MATCH_VALUE_INIT(cfg, pid); + USB_MATCH_VALUE_INIT(cfg, bus); + USB_MATCH_VALUE_INIT(cfg, address); + USB_MATCH_VALUE_INIT(cfg, config); + USB_MATCH_VALUE_INIT(cfg, interface); + USB_MATCH_VALUE_INIT(cfg, altsetting); + USB_MATCH_VALUE_INIT(cfg, class); + USB_MATCH_VALUE_INIT(cfg, subclass); + USB_MATCH_VALUE_INIT(cfg, protocol); } void usb_match_value_default(struct usb_match_value *value, -- To view, visit
https://review.coreboot.org/c/flashrom/+/66670
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I85ff3117de8743b0a548dad98875cc41f48cac93 Gerrit-Change-Number: 66670 Gerrit-PatchSet: 10 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-MessageType: merged
1
0
0
0
[M] Change in flashrom[master]: tree: Port programmers to pass programmer_cfg to extractors
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66656
) Change subject: tree: Port programmers to pass programmer_cfg to extractors ...................................................................... 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 <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66656
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> --- M atavia.c M buspirate_spi.c M chipset_enable.c M dediprog.c M developerbox_spi.c M digilent_spi.c M dummyflasher.c M ft2232_spi.c M i2c_helper_linux.c M include/i2c_helper.h M internal.c M it87spi.c M jlink_spi.c M linux_mtd.c M linux_spi.c M mediatek_i2c_spi.c M mstarddc_spi.c M ni845x_spi.c M ogp_spi.c M parade_lspcon.c M pcidev.c M pickit2_spi.c M pony_spi.c M raiden_debug_spi.c M rayer_spi.c M realtek_mst_i2c_spi.c M sb600spi.c M serprog.c M stlinkv3_spi.c M usb_device.c 30 files changed, 113 insertions(+), 85 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/atavia.c b/atavia.c index 4507820..6e64bb4 100644 --- a/atavia.c +++ b/atavia.c @@ -145,7 +145,7 @@ 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 8aa7243..8fa60f6 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -332,7 +332,7 @@ 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 @@ 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 @@ 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 @@ } 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 @@ } 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 7a98fd4..e57493f 100644 --- a/chipset_enable.c +++ b/chipset_enable.c @@ -428,7 +428,7 @@ 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 cd11505..f957be6 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1087,7 +1087,7 @@ 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 @@ 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 @@ 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 @@ } 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 @@ } 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 16fa351..3774d04 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -152,7 +152,7 @@ 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 b6e998d..41342a8 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -408,7 +408,7 @@ 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 @@ 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 bd97524..07fcd72 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -958,7 +958,7 @@ 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 @@ 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 @@ } 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 @@ } 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 @@ 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 @@ } 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ 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 c7dbbb2..2971c2e 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -340,7 +340,7 @@ 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 @@ /* 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 @@ } 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 @@ 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 @@ 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 @@ 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 29fdfd4..19b4404 100644 --- a/i2c_helper_linux.c +++ b/i2c_helper_linux.c @@ -96,12 +96,12 @@ 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 c7d0f7a..b840b3a 100644 --- a/include/i2c_helper.h +++ b/include/i2c_helper.h @@ -19,6 +19,8 @@ #include <inttypes.h> +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 @@ * 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 8b97f53..18ac088 100644 --- a/internal.c +++ b/internal.c @@ -129,7 +129,7 @@ *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 @@ } 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 @@ } 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 @@ } 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 bef60cb..eb04141 100644 --- a/it87spi.c +++ b/it87spi.c @@ -328,7 +328,7 @@ 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 @@ 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 48239f3..52fc786 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -203,7 +203,7 @@ 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 @@ 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 @@ 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 @@ 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 ef90885..c5dc451 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -500,7 +500,7 @@ 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 b54ab17..09ee8a0 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -177,7 +177,7 @@ 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 @@ } 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 c460da1..39a9cea 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -470,7 +470,7 @@ 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 @@ 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 5b9e40e..ee5779c 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -159,7 +159,7 @@ 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 @@ 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 0096307..3d74fd9 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -553,7 +553,7 @@ 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 @@ } } - 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 @@ 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 @@ } 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 a994cb9..47a3d80 100644 --- a/ogp_spi.c +++ b/ogp_spi.c @@ -117,7 +117,7 @@ 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 a82cc31..761e46b 100644 --- a/parade_lspcon.c +++ b/parade_lspcon.c @@ -446,7 +446,7 @@ 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 @@ 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 2fbc1e5..72561f0 100644 --- a/pcidev.c +++ b/pcidev.c @@ -272,7 +272,7 @@ 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 312eaea..b838234 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -412,7 +412,7 @@ 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 @@ } 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 69be3aa..04c3236 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -130,7 +130,7 @@ *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 @@ } 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 d2eea6a..2f073ae 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1432,7 +1432,7 @@ 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 @@ */ 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 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 95f7bbc..3867cfc 100644 --- a/rayer_spi.c +++ b/rayer_spi.c @@ -244,7 +244,7 @@ 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 @@ 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 c4482ac..74458c8 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -450,7 +450,7 @@ 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 @@ 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 @@ 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 @@ 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 b5d10bc..40a6dbb 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -416,7 +416,7 @@ 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 @@ 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 @@ 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 e025893..c68449a 100644 --- a/serprog.c +++ b/serprog.c @@ -574,7 +574,7 @@ 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 @@ } 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 @@ 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 07fdedd..38fe9f9 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -490,7 +490,7 @@ 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 @@ } 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 3869bbf..f89e3bb 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; -- To view, visit
https://review.coreboot.org/c/flashrom/+/66656
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: If7b7987e803d35582dda219652a6fc3ed5729b47 Gerrit-Change-Number: 66656 Gerrit-PatchSet: 11 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: Nikolai Artemiev <nartemiev(a)google.com> Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-MessageType: merged
1
0
0
0
[S] Change in flashrom[master]: raiden_debug_spi.c: plumb programmer_cfg though get_params
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66667
) Change subject: raiden_debug_spi.c: plumb programmer_cfg though get_params ...................................................................... raiden_debug_spi.c: plumb programmer_cfg though get_params Modify the type signature of the programmer get_param helper functions to allow for the consumption of the programmer parameterisation string data. Change-Id: I20041a9aead513de71c2c384842046f64c1614b6 Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66667
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> --- M raiden_debug_spi.c 1 file changed, 22 insertions(+), 4 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index c6689ac..d2eea6a 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1429,7 +1429,7 @@ return 0; } -static int get_ap_request_type(void) +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"); @@ -1448,7 +1448,7 @@ return ap_request; } -static int get_target(void) +static int get_target(const struct programmer_cfg *cfg) { /** * REQ_ENABLE doesn't specify a target bus, and will be rejected @@ -1459,7 +1459,7 @@ char *target_str = extract_programmer_param_str(NULL, "target"); if (target_str) { if (!strcasecmp(target_str, "ap")) - request_enable = get_ap_request_type(); + request_enable = get_ap_request_type(cfg); else if (!strcasecmp(target_str, "ec")) request_enable = RAIDEN_DEBUG_SPI_REQ_ENABLE_EC; else { @@ -1491,7 +1491,7 @@ int found = 0; int ret; - int request_enable = get_target(); + int request_enable = get_target(cfg); if (request_enable < 0) { free(serial); return 1; -- To view, visit
https://review.coreboot.org/c/flashrom/+/66667
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I20041a9aead513de71c2c384842046f64c1614b6 Gerrit-Change-Number: 66667 Gerrit-PatchSet: 9 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-MessageType: merged
1
0
0
0
[S] Change in flashrom[master]: dummyflasher.c: plumb programmer_cfg though get_params
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66663
) Change subject: dummyflasher.c: plumb programmer_cfg though get_params ...................................................................... dummyflasher.c: plumb programmer_cfg though get_params Modify the type signature of the programmer get_param helper functions to allow for the consumption of the programmer parameterisation string data. Change-Id: Ic5b35a7324b1c5a8ca9b8b16ee0b95036737ef47 Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66663
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> --- M dummyflasher.c 1 file changed, 21 insertions(+), 2 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/dummyflasher.c b/dummyflasher.c index f27ad46..bd97524 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -948,7 +948,8 @@ .erase = dummy_opaque_erase, }; -static int init_data(struct emu_data *data, enum chipbustype *dummy_buses_supported) +static int init_data(const struct programmer_cfg *cfg, + struct emu_data *data, enum chipbustype *dummy_buses_supported) { char *bustext = NULL; char *tmp = NULL; @@ -1354,7 +1355,7 @@ msg_pspew("%s\n", __func__); enum chipbustype dummy_buses_supported; - if (init_data(data, &dummy_buses_supported)) { + if (init_data(cfg, data, &dummy_buses_supported)) { free(data); return 1; } -- To view, visit
https://review.coreboot.org/c/flashrom/+/66663
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: Ic5b35a7324b1c5a8ca9b8b16ee0b95036737ef47 Gerrit-Change-Number: 66663 Gerrit-PatchSet: 9 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-MessageType: merged
1
0
0
0
[S] Change in flashrom[master]: sb600spi.c: Allow passing programmer_cfg directly
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66660
) Change subject: sb600spi.c: Allow passing programmer_cfg directly ...................................................................... sb600spi.c: Allow passing programmer_cfg directly Modify the type signature of the programmer entry-point xxx_init() functions to allow for the consumption of the programmer parameterisation string data. Also plumb programmer_cfg though handle_imc and handle_speed. Change-Id: I82f9ee75df90c582ef345c00a5487c687f28cdd5 Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66660
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> --- M chipset_enable.c M include/programmer.h M sb600spi.c 3 files changed, 27 insertions(+), 7 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/chipset_enable.c b/chipset_enable.c index 5f46fbf..7a98fd4 100644 --- a/chipset_enable.c +++ b/chipset_enable.c @@ -1407,7 +1407,7 @@ internal_buses_supported &= BUS_LPC | BUS_FWH; - ret = sb600_probe_spi(dev); + ret = sb600_probe_spi(NULL, dev); /* TODO(quasisec): pass prog_param */ /* Read ROM strap override register. */ OUTB(0x8f, 0xcd6); diff --git a/include/programmer.h b/include/programmer.h index 1372e2b..4ed68da 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -387,7 +387,7 @@ /* sb600spi.c */ -int sb600_probe_spi(struct pci_dev *dev); +int sb600_probe_spi(const struct programmer_cfg *cfg, struct pci_dev *dev); /* wbsio_spi.c */ int wbsio_check_for_spi(void); diff --git a/sb600spi.c b/sb600spi.c index df8d726..b5d10bc 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -408,7 +408,8 @@ return 0; } -static int handle_speed(struct pci_dev *dev, enum amd_chipset amd_gen, uint8_t *sb600_spibar) +static int handle_speed(const struct programmer_cfg *cfg, + struct pci_dev *dev, enum amd_chipset amd_gen, uint8_t *sb600_spibar) { uint32_t tmp; int16_t spispeed_idx = -1; @@ -521,7 +522,7 @@ return set_speed(dev, amd_gen, spispeed_idx, sb600_spibar); } -static int handle_imc(struct pci_dev *dev, enum amd_chipset amd_gen) +static int handle_imc(const struct programmer_cfg *cfg, struct pci_dev *dev, enum amd_chipset amd_gen) { /* Handle IMC everywhere but sb600 which does not have one. */ if (amd_gen == CHIPSET_SB6XX) @@ -629,7 +630,7 @@ .probe_opcode = default_spi_probe_opcode, }; -int sb600_probe_spi(struct pci_dev *dev) +int sb600_probe_spi(const struct programmer_cfg *cfg, struct pci_dev *dev) { struct pci_dev *smbus_dev; uint32_t tmp; @@ -789,10 +790,10 @@ return 0; } - if (handle_speed(dev, amd_gen, sb600_spibar) != 0) + if (handle_speed(cfg, dev, amd_gen, sb600_spibar) != 0) return ERROR_FATAL; - if (handle_imc(dev, amd_gen) != 0) + if (handle_imc(cfg, dev, amd_gen) != 0) return ERROR_FATAL; struct sb600spi_data *data = calloc(1, sizeof(*data)); -- To view, visit
https://review.coreboot.org/c/flashrom/+/66660
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I82f9ee75df90c582ef345c00a5487c687f28cdd5 Gerrit-Change-Number: 66660 Gerrit-PatchSet: 9 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-MessageType: merged
1
0
0
0
[S] Change in flashrom[master]: it87spi.c: Allow passing programmer_cfg directly
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66662
) Change subject: it87spi.c: Allow passing programmer_cfg directly ...................................................................... it87spi.c: Allow passing programmer_cfg directly Modify the type signature of the programmer entry-point xxx_init() functions to allow for the consumption of the programmer parameterisation string data. Change-Id: I598b1811c9734f41eee205d5a2b51ad8ac79e3ab Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66662
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> --- M include/programmer.h M internal.c M it87spi.c 3 files changed, 23 insertions(+), 5 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/include/programmer.h b/include/programmer.h index 95e25ca..1372e2b 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -372,7 +372,7 @@ void enter_conf_mode_ite(uint16_t port); void exit_conf_mode_ite(uint16_t port); void probe_superio_ite(void); -int init_superio_ite(void); +int init_superio_ite(const struct programmer_cfg *cfg); #if CONFIG_LINUX_MTD == 1 /* trivial wrapper to avoid cluttering internal_init() with #if */ diff --git a/internal.c b/internal.c index 66eebdc..8b97f53 100644 --- a/internal.c +++ b/internal.c @@ -293,7 +293,7 @@ #if defined(__i386__) || defined(__x86_64__) /* Probe unconditionally for ITE Super I/O chips. This enables LPC->SPI translation on IT87* and * parallel writes on IT8705F. Also, this handles the manual chip select for Gigabyte's DualBIOS. */ - init_superio_ite(); + init_superio_ite(cfg); if (board_flash_enable(board_vendor, board_model, cb_vendor, cb_model)) { msg_perr("Aborting to be safe.\n"); diff --git a/it87spi.c b/it87spi.c index 568d714..bef60cb 100644 --- a/it87spi.c +++ b/it87spi.c @@ -321,7 +321,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static uint16_t it87spi_probe(uint16_t port) +static uint16_t it87spi_probe(const struct programmer_cfg *cfg, uint16_t port) { uint8_t tmp = 0; uint16_t flashport = 0; @@ -440,7 +440,7 @@ return register_spi_master(&spi_master_it87xx, data); } -int init_superio_ite(void) +int init_superio_ite(const struct programmer_cfg *cfg) { int i; int ret = 0; @@ -458,7 +458,7 @@ case 0x8718: case 0x8720: case 0x8728: - ret |= it87spi_probe(superios[i].port); + ret |= it87spi_probe(cfg, superios[i].port); break; default: msg_pdbg2("Super I/O ID 0x%04hx is not on the list of flash-capable controllers.\n", -- To view, visit
https://review.coreboot.org/c/flashrom/+/66662
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I598b1811c9734f41eee205d5a2b51ad8ac79e3ab Gerrit-Change-Number: 66662 Gerrit-PatchSet: 9 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-MessageType: merged
1
0
0
0
[M] Change in flashrom[master]: tree: Allow passing programmer_cfg directly to programmer
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66655
) Change subject: tree: Allow passing programmer_cfg directly to programmer ...................................................................... tree: Allow passing programmer_cfg directly to programmer Modify the type signature of each programmer entry-point xxx_init() functions to allow for the consumption of the programmer parameterisation string data. ``` $ find -name '*.c' -exec sed -i 's/_init(void)/_init(const char *prog_param)/g' '{}' \; $ find -name '*.c' -exec sed -i 's/get_params(/get_params(const char *prog_param, /g' '{}' \; $ find -name '*.c' -exec sed -i 's/const char \*prog_param)/const struct programmer_cfg *cfg)/g' '{}' \; $ find -name '*.c' -exec sed -i 's/const char \*prog_param,/const struct programmer_cfg *cfg,/g' '{}' \; ``` and manually fix up any remaining parts. Change-Id: I8bab51a635b9d3a43e1619a7a32b334f4ce2cdd2 Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66655
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> --- M atahpt.c M atapromise.c M atavia.c M buspirate_spi.c M ch341a_spi.c M dediprog.c M developerbox_spi.c M digilent_spi.c M drkaiser.c M dummyflasher.c M flashrom.c M ft2232_spi.c M gfxnvidia.c M include/programmer.h M internal.c M it8212.c M jlink_spi.c M linux_mtd.c M linux_spi.c M mediatek_i2c_spi.c M mstarddc_spi.c M ni845x_spi.c M nic3com.c M nicintel.c M nicintel_eeprom.c M nicintel_spi.c M nicnatsemi.c M nicrealtek.c M ogp_spi.c M parade_lspcon.c M pickit2_spi.c M pony_spi.c M raiden_debug_spi.c M rayer_spi.c M realtek_mst_i2c_spi.c M satamv.c M satasii.c M serprog.c M stlinkv3_spi.c M usbblaster_spi.c 40 files changed, 79 insertions(+), 51 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/atahpt.c b/atahpt.c index 1cefef3..2ab51a8 100644 --- a/atahpt.c +++ b/atahpt.c @@ -84,7 +84,7 @@ .shutdown = atahpt_shutdown, }; -static int atahpt_init(void) +static int atahpt_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t io_base_addr; diff --git a/atapromise.c b/atapromise.c index a901e8b..4be2f71 100644 --- a/atapromise.c +++ b/atapromise.c @@ -129,7 +129,7 @@ .shutdown = atapromise_shutdown, }; -static int atapromise_init(void) +static int atapromise_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t io_base_addr; diff --git a/atavia.c b/atavia.c index fe86664..4507820 100644 --- a/atavia.c +++ b/atavia.c @@ -143,7 +143,7 @@ .chip_writen = fallback_chip_writen, }; -static int atavia_init(void) +static int atavia_init(const struct programmer_cfg *cfg) { char *arg = extract_programmer_param_str(NULL, "offset"); if (arg) { diff --git a/buspirate_spi.c b/buspirate_spi.c index 2fcf445..8aa7243 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -314,7 +314,7 @@ */ #define BP_DIVISOR(baud) ((4000000/(baud)) - 1) -static int buspirate_spi_init(void) +static int buspirate_spi_init(const struct programmer_cfg *cfg) { char *tmp; char *dev; diff --git a/ch341a_spi.c b/ch341a_spi.c index 3978d99..78b9cee 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -420,7 +420,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static int ch341a_spi_init(void) +static int ch341a_spi_init(const struct programmer_cfg *cfg) { if (handle != NULL) { msg_cerr("%s: handle already set! Please report a bug at flashrom(a)flashrom.org\n", __func__); diff --git a/dediprog.c b/dediprog.c index 86d72aa..cd11505 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1076,7 +1076,7 @@ return 0; } -static int dediprog_init(void) +static int dediprog_init(const struct programmer_cfg *cfg) { char *param_str; int spispeed_idx = 1; diff --git a/developerbox_spi.c b/developerbox_spi.c index d585418..16fa351 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -142,7 +142,7 @@ return 0; } -static int developerbox_spi_init(void) +static int developerbox_spi_init(const struct programmer_cfg *cfg) { struct libusb_context *usb_ctx; libusb_device_handle *cp210x_handle; diff --git a/digilent_spi.c b/digilent_spi.c index a16ae7b..b6e998d 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -374,7 +374,7 @@ { NULL, 0 }, }; -static int digilent_spi_init(void) +static int digilent_spi_init(const struct programmer_cfg *cfg) { char *param_str; uint32_t speed_hz = spispeeds[0].speed; diff --git a/drkaiser.c b/drkaiser.c index 9267dfe..2fb6b91 100644 --- a/drkaiser.c +++ b/drkaiser.c @@ -81,7 +81,7 @@ .shutdown = drkaiser_shutdown, }; -static int drkaiser_init(void) +static int drkaiser_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t addr; diff --git a/dummyflasher.c b/dummyflasher.c index 03c7f27..f27ad46 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -1338,7 +1338,7 @@ return 0; } -static int dummy_init(void) +static int dummy_init(const struct programmer_cfg *cfg) { struct stat image_stat; diff --git a/flashrom.c b/flashrom.c index 5b7bbbd..0e2fa42 100644 --- a/flashrom.c +++ b/flashrom.c @@ -151,7 +151,7 @@ programmer_param = param; msg_pdbg("Initializing %s programmer\n", programmer->name); - ret = programmer->init(); + ret = programmer->init(NULL); if (programmer_param && strlen(programmer_param)) { if (ret != 0) { /* It is quite possible that any unhandled programmer parameter would have been valid, diff --git a/ft2232_spi.c b/ft2232_spi.c index 7c31013..c7dbbb2 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -304,7 +304,7 @@ }; /* Returns 0 upon success, a negative number upon errors. */ -static int ft2232_spi_init(void) +static int ft2232_spi_init(const struct programmer_cfg *cfg) { int ret = 0; unsigned char buf[512]; diff --git a/gfxnvidia.c b/gfxnvidia.c index 0da3e8d..19fa2b6 100644 --- a/gfxnvidia.c +++ b/gfxnvidia.c @@ -105,7 +105,7 @@ .shutdown = gfxnvidia_shutdown, }; -static int gfxnvidia_init(void) +static int gfxnvidia_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t reg32; diff --git a/include/programmer.h b/include/programmer.h index c58459f..95e25ca 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -47,7 +47,7 @@ const char *const note; } devs; - int (*init) (void); + int (*init) (const struct programmer_cfg *cfg); void *(*map_flash_region) (const char *descr, uintptr_t phys_addr, size_t len); void (*unmap_flash_region) (void *virt_addr, size_t len); @@ -376,7 +376,7 @@ #if CONFIG_LINUX_MTD == 1 /* trivial wrapper to avoid cluttering internal_init() with #if */ -static inline int try_mtd(void) { return programmer_linux_mtd.init(); }; +static inline int try_mtd(void) { return programmer_linux_mtd.init(NULL); }; #else static inline int try_mtd(void) { return 1; }; #endif diff --git a/internal.c b/internal.c index 8e267cd..66eebdc 100644 --- a/internal.c +++ b/internal.c @@ -116,7 +116,8 @@ .chip_writen = fallback_chip_writen, }; -static int get_params(int *boardenable, int *boardmismatch, +static int get_params(const struct programmer_cfg *cfg, + int *boardenable, int *boardmismatch, int *force_laptop, int *not_a_laptop, char **board_vendor, char **board_model) { @@ -188,7 +189,7 @@ return 0; } -static int internal_init(void) +static int internal_init(const struct programmer_cfg *cfg) { int ret = 0; int force_laptop; @@ -200,7 +201,8 @@ const char *cb_model = NULL; #endif - ret = get_params(&force_boardenable, &force_boardmismatch, + ret = get_params(cfg, + &force_boardenable, &force_boardmismatch, &force_laptop, ¬_a_laptop, &board_vendor, &board_model); if (ret) diff --git a/it8212.c b/it8212.c index ac8126c..4d73665 100644 --- a/it8212.c +++ b/it8212.c @@ -74,7 +74,7 @@ .shutdown = it8212_shutdown, }; -static int it8212_init(void) +static int it8212_init(const struct programmer_cfg *cfg) { uint8_t *bar; diff --git a/jlink_spi.c b/jlink_spi.c index eba8dbc..48239f3 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -193,7 +193,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static int jlink_spi_init(void) +static int jlink_spi_init(const struct programmer_cfg *cfg) { char *arg; unsigned long speed = 0; diff --git a/linux_mtd.c b/linux_mtd.c index 414a6b4..ef90885 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -493,7 +493,7 @@ return ret; } -static int linux_mtd_init(void) +static int linux_mtd_init(const struct programmer_cfg *cfg) { char *param_str; int dev_num = 0; diff --git a/linux_spi.c b/linux_spi.c index cef7909..b54ab17 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -165,7 +165,7 @@ return result; } -static int linux_spi_init(void) +static int linux_spi_init(const struct programmer_cfg *cfg) { char *param_str, *endp; uint32_t speed_hz = 2 * 1000 * 1000; diff --git a/mediatek_i2c_spi.c b/mediatek_i2c_spi.c index 4133edb..c460da1 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -464,7 +464,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static int get_params(bool *allow_brick) +static int get_params(const struct programmer_cfg *cfg, bool *allow_brick) { char *brick_str = NULL; int ret = 0; @@ -484,12 +484,12 @@ return ret; } -static int mediatek_init(void) +static int mediatek_init(const struct programmer_cfg *cfg) { int ret; bool allow_brick; - if (get_params(&allow_brick)) + if (get_params(cfg, &allow_brick)) return SPI_GENERIC_ERROR; /* diff --git a/mstarddc_spi.c b/mstarddc_spi.c index 50a75d3..5b9e40e 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -150,7 +150,7 @@ }; /* Returns 0 upon success, a negative number upon errors. */ -static int mstarddc_spi_init(void) +static int mstarddc_spi_init(const struct programmer_cfg *cfg) { int ret = 0; int mstarddc_fd = -1; diff --git a/ni845x_spi.c b/ni845x_spi.c index f75c399..0096307 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -540,7 +540,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static int ni845x_spi_init(void) +static int ni845x_spi_init(const struct programmer_cfg *cfg) { char *speed_str = NULL; char *CS_str = NULL; diff --git a/nic3com.c b/nic3com.c index de7a5e5..fd4fe2b 100644 --- a/nic3com.c +++ b/nic3com.c @@ -101,7 +101,7 @@ .shutdown = nic3com_shutdown, }; -static int nic3com_init(void) +static int nic3com_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t io_base_addr = 0; diff --git a/nicintel.c b/nicintel.c index e165611..9ef0315 100644 --- a/nicintel.c +++ b/nicintel.c @@ -77,7 +77,7 @@ .shutdown = nicintel_shutdown, }; -static int nicintel_init(void) +static int nicintel_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uintptr_t addr; diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c index c09c1d1..8e59a45 100644 --- a/nicintel_eeprom.c +++ b/nicintel_eeprom.c @@ -479,7 +479,7 @@ .shutdown = nicintel_ee_shutdown_i210, }; -static int nicintel_ee_init(void) +static int nicintel_ee_init(const struct programmer_cfg *cfg) { const struct opaque_master *mst; uint32_t eec = 0; diff --git a/nicintel_spi.c b/nicintel_spi.c index 54d1c3c..74cb122 100644 --- a/nicintel_spi.c +++ b/nicintel_spi.c @@ -285,7 +285,7 @@ return 0; } -static int nicintel_spi_init(void) +static int nicintel_spi_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; diff --git a/nicnatsemi.c b/nicnatsemi.c index 9d98155..b9c58bc 100644 --- a/nicnatsemi.c +++ b/nicnatsemi.c @@ -88,7 +88,7 @@ .shutdown = nicnatsemi_shutdown, }; -static int nicnatsemi_init(void) +static int nicnatsemi_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t io_base_addr; diff --git a/nicrealtek.c b/nicrealtek.c index ebe9dab..61eb38b 100644 --- a/nicrealtek.c +++ b/nicrealtek.c @@ -97,7 +97,7 @@ .shutdown = nicrealtek_shutdown, }; -static int nicrealtek_init(void) +static int nicrealtek_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t io_base_addr = 0; diff --git a/ogp_spi.c b/ogp_spi.c index b3c404c..a994cb9 100644 --- a/ogp_spi.c +++ b/ogp_spi.c @@ -107,7 +107,7 @@ return 0; } -static int ogp_spi_init(void) +static int ogp_spi_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; char *type; diff --git a/parade_lspcon.c b/parade_lspcon.c index 815f398..a82cc31 100644 --- a/parade_lspcon.c +++ b/parade_lspcon.c @@ -440,7 +440,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static int get_params(bool *allow_brick) +static int get_params(const struct programmer_cfg *cfg, bool *allow_brick) { char *brick_str = NULL; int ret = 0; @@ -460,11 +460,11 @@ return ret; } -static int parade_lspcon_init(void) +static int parade_lspcon_init(const struct programmer_cfg *cfg) { bool allow_brick; - if (get_params(&allow_brick)) + if (get_params(cfg, &allow_brick)) return SPI_GENERIC_ERROR; /* diff --git a/pickit2_spi.c b/pickit2_spi.c index 7c84d96..312eaea 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -388,7 +388,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static int pickit2_spi_init(void) +static int pickit2_spi_init(const struct programmer_cfg *cfg) { uint8_t buf[CMD_LENGTH] = { CMD_EXEC_SCRIPT, diff --git a/pony_spi.c b/pony_spi.c index 50f44da..69be3aa 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -120,7 +120,7 @@ return ret; } -static int get_params(enum pony_type *type, int *have_device) +static int get_params(const struct programmer_cfg *cfg, enum pony_type *type, int *have_device) { char *arg = NULL; int ret = 0; @@ -159,7 +159,7 @@ return ret; } -static int pony_spi_init(void) +static int pony_spi_init(const struct programmer_cfg *cfg) { int i, data_out; enum pony_type type; @@ -167,7 +167,7 @@ int have_device; int have_prog = 0; - if (get_params(&type, &have_device)) { + if (get_params(cfg, &type, &have_device)) { serialport_shutdown(NULL); return 1; } diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index 3382b9e..c6689ac 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1482,7 +1482,7 @@ dev = usb_device_free(dev); } -static int raiden_debug_spi_init(void) +static int raiden_debug_spi_init(const struct programmer_cfg *cfg) { struct usb_match match; char *serial = extract_programmer_param_str(NULL, "serial"); diff --git a/rayer_spi.c b/rayer_spi.c index 82c49b3..95f7bbc 100644 --- a/rayer_spi.c +++ b/rayer_spi.c @@ -235,7 +235,7 @@ .half_period = 0, }; -static int rayer_spi_init(void) +static int rayer_spi_init(const struct programmer_cfg *cfg) { const struct rayer_programmer *prog = rayer_spi_types; char *arg = NULL; diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index 6c2b86f..c4482ac 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -444,7 +444,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static int get_params(bool *reset, bool *enter_isp, bool *allow_brick) +static int get_params(const struct programmer_cfg *cfg, bool *reset, bool *enter_isp, bool *allow_brick) { char *param_str; int ret = 0; @@ -492,12 +492,12 @@ return ret; } -static int realtek_mst_i2c_spi_init(void) +static int realtek_mst_i2c_spi_init(const struct programmer_cfg *cfg) { int ret = 0; bool reset, enter_isp, allow_brick; - if (get_params(&reset, &enter_isp, &allow_brick)) + if (get_params(cfg, &reset, &enter_isp, &allow_brick)) return SPI_GENERIC_ERROR; /* diff --git a/satamv.c b/satamv.c index 8c79f08..19ecf22 100644 --- a/satamv.c +++ b/satamv.c @@ -114,7 +114,7 @@ * 0xc08 PCI BAR2 (Flash/NVRAM) Control * 0x1046c Flash Parameters */ -static int satamv_init(void) +static int satamv_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uintptr_t addr; diff --git a/satasii.c b/satasii.c index 7e795c2..a56171b 100644 --- a/satasii.c +++ b/satasii.c @@ -105,7 +105,7 @@ .shutdown = satasii_shutdown, }; -static int satasii_init(void) +static int satasii_init(const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t addr; diff --git a/serprog.c b/serprog.c index 4480285..e025893 100644 --- a/serprog.c +++ b/serprog.c @@ -564,7 +564,7 @@ static enum chipbustype serprog_buses_supported = BUS_NONE; -static int serprog_init(void) +static int serprog_init(const struct programmer_cfg *cfg) { uint16_t iface; unsigned char pgmname[17]; diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index ccba1d9..07fdedd 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -474,7 +474,7 @@ .probe_opcode = default_spi_probe_opcode, }; -static int stlinkv3_spi_init(void) +static int stlinkv3_spi_init(const struct programmer_cfg *cfg) { uint16_t sck_freq_kHz = 1000; // selecting 1 MHz SCK is a good bet char *param_str; diff --git a/usbblaster_spi.c b/usbblaster_spi.c index b1ab80a..2880a3c 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -177,7 +177,7 @@ }; /* Returns 0 upon success, a negative number upon errors. */ -static int usbblaster_spi_init(void) +static int usbblaster_spi_init(const struct programmer_cfg *cfg) { uint8_t buf[BUF_SIZE + 1] = { 0 }; struct ftdi_context ftdic; -- To view, visit
https://review.coreboot.org/c/flashrom/+/66655
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I8bab51a635b9d3a43e1619a7a32b334f4ce2cdd2 Gerrit-Change-Number: 66655 Gerrit-PatchSet: 9 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: Nikolai Artemiev <nartemiev(a)google.com> Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-MessageType: merged
1
0
0
0
[M] Change in flashrom[master]: tree: Change signature of extract_programmer_param_str()
by Anastasia Klimchuk (Code Review)
07 Sep '22
07 Sep '22
Anastasia Klimchuk has submitted this change. (
https://review.coreboot.org/c/flashrom/+/66654
) Change subject: tree: Change signature of extract_programmer_param_str() ...................................................................... tree: Change signature of extract_programmer_param_str() Results can be reproduced with the following invocation; ``` $ find -name '*.c' -exec sed -i 's/extract_programmer_param_str(/extract_programmer_param_str(NULL, /g' '{}' \; ``` This allows for a pointer to the actual programmer parameters to be passed instead of a global. Change-Id: I781a328fa280e0a9601050dd99a75af72c39c899 Signed-off-by: Edward O'Callaghan <quasisec(a)google.com> Reviewed-on:
https://review.coreboot.org/c/flashrom/+/66654
Tested-by: build bot (Jenkins) <no-reply(a)coreboot.org> Reviewed-by: Felix Singer <felixsinger(a)posteo.net> Reviewed-by: Anastasia Klimchuk <aklm(a)chromium.org> --- M atavia.c M buspirate_spi.c M chipset_enable.c M dediprog.c M developerbox_spi.c M digilent_spi.c M dummyflasher.c M flashrom.c M ft2232_spi.c M i2c_helper_linux.c M ichspi.c M include/programmer.h M internal.c M it87spi.c M jlink_spi.c M linux_mtd.c M linux_spi.c M mediatek_i2c_spi.c M mstarddc_spi.c M ni845x_spi.c M ogp_spi.c M parade_lspcon.c M pcidev.c M pickit2_spi.c M pony_spi.c M raiden_debug_spi.c M rayer_spi.c M realtek_mst_i2c_spi.c M sb600spi.c M serprog.c M stlinkv3_spi.c M usb_device.c 32 files changed, 110 insertions(+), 83 deletions(-) Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Anastasia Klimchuk: Looks good to me, approved diff --git a/atavia.c b/atavia.c index bce7138..fe86664 100644 --- a/atavia.c +++ b/atavia.c @@ -145,7 +145,7 @@ static int atavia_init(void) { - char *arg = extract_programmer_param_str("offset"); + char *arg = extract_programmer_param_str(NULL, "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 f905a96..2fcf445 100644 --- a/buspirate_spi.c +++ b/buspirate_spi.c @@ -332,7 +332,7 @@ unsigned char *bp_commbuf; int bp_commbufsize; - dev = extract_programmer_param_str("dev"); + dev = extract_programmer_param_str(NULL, "dev"); if (dev && !strlen(dev)) { free(dev); dev = NULL; @@ -342,7 +342,7 @@ return 1; } - tmp = extract_programmer_param_str("spispeed"); + tmp = extract_programmer_param_str(NULL, "spispeed"); if (tmp) { for (i = 0; spispeeds[i].name; i++) { if (!strncasecmp(spispeeds[i].name, tmp, strlen(spispeeds[i].name))) { @@ -356,7 +356,7 @@ free(tmp); /* Extract serialspeed parameter */ - tmp = extract_programmer_param_str("serialspeed"); + tmp = extract_programmer_param_str(NULL, "serialspeed"); if (tmp) { for (i = 0; serialspeeds[i].name; i++) { if (!strncasecmp(serialspeeds[i].name, tmp, strlen(serialspeeds[i].name))) { @@ -369,7 +369,7 @@ } free(tmp); - tmp = extract_programmer_param_str("pullups"); + tmp = extract_programmer_param_str(NULL, "pullups"); if (tmp) { if (strcasecmp("on", tmp) == 0) pullup = 1; @@ -380,7 +380,7 @@ } free(tmp); - tmp = extract_programmer_param_str("psus"); + tmp = extract_programmer_param_str(NULL, "psus"); if (tmp) { if (strcasecmp("on", tmp) == 0) psu = 1; diff --git a/chipset_enable.c b/chipset_enable.c index 9790bc9..5f46fbf 100644 --- a/chipset_enable.c +++ b/chipset_enable.c @@ -428,7 +428,7 @@ break; } - char *idsel = extract_programmer_param_str("fwh_idsel"); + char *idsel = extract_programmer_param_str(NULL, "fwh_idsel"); 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 e5bf84e..86d72aa 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1087,7 +1087,7 @@ long target = FLASH_TYPE_APPLICATION_FLASH_1; int i, ret; - param_str = extract_programmer_param_str("spispeed"); + param_str = extract_programmer_param_str(NULL, "spispeed"); if (param_str) { for (i = 0; spispeeds[i].name; ++i) { if (!strcasecmp(spispeeds[i].name, param_str)) { @@ -1103,7 +1103,7 @@ free(param_str); } - param_str = extract_programmer_param_str("voltage"); + param_str = extract_programmer_param_str(NULL, "voltage"); if (param_str) { millivolt = parse_voltage(param_str); free(param_str); @@ -1112,7 +1112,7 @@ msg_pinfo("Setting voltage to %i mV\n", millivolt); } - param_str = extract_programmer_param_str("id"); + param_str = extract_programmer_param_str(NULL, "id"); if (param_str) { char prefix0, prefix1; if (sscanf(param_str, "%c%c%d", &prefix0, &prefix1, &id) != 3) { @@ -1135,7 +1135,7 @@ } free(param_str); - param_str = extract_programmer_param_str("device"); + param_str = extract_programmer_param_str(NULL, "device"); if (param_str) { char *dev_suffix; if (id != -1) { @@ -1162,7 +1162,7 @@ } free(param_str); - param_str = extract_programmer_param_str("target"); + param_str = extract_programmer_param_str(NULL, "target"); if (param_str) { char *target_suffix; errno = 0; diff --git a/developerbox_spi.c b/developerbox_spi.c index 6308da6..d585418 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -152,7 +152,7 @@ return 1; } - char *serialno = extract_programmer_param_str("serial"); + char *serialno = extract_programmer_param_str(NULL, "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 d251f09..a16ae7b 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -408,7 +408,7 @@ goto close_handle; } - param_str = extract_programmer_param_str("spispeed"); + param_str = extract_programmer_param_str(NULL, "spispeed"); if (param_str) { for (i = 0; spispeeds[i].name; ++i) { if (!strcasecmp(spispeeds[i].name, param_str)) { @@ -424,7 +424,7 @@ free(param_str); } - param_str = extract_programmer_param_str("reset"); + param_str = extract_programmer_param_str(NULL, "reset"); if (param_str && strlen(param_str)) reset_board = (param_str[0] == '1'); else diff --git a/dummyflasher.c b/dummyflasher.c index 93ad31c..03c7f27 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -957,7 +957,7 @@ char *status = NULL; int size = -1; /* size for VARIABLE_SIZE chip device */ - bustext = extract_programmer_param_str("bus"); + bustext = extract_programmer_param_str(NULL, "bus"); msg_pdbg("Requested buses are: %s\n", bustext ? bustext : "default"); if (!bustext) bustext = strdup("parallel+lpc+fwh+spi+prog"); @@ -989,7 +989,7 @@ msg_pdbg("Support for all flash bus types disabled.\n"); free(bustext); - tmp = extract_programmer_param_str("spi_write_256_chunksize"); + tmp = extract_programmer_param_str(NULL, "spi_write_256_chunksize"); if (tmp) { data->spi_write_256_chunksize = strtoul(tmp, &endptr, 0); if (*endptr != '\0' || data->spi_write_256_chunksize < 1) { @@ -1000,7 +1000,7 @@ } free(tmp); - tmp = extract_programmer_param_str("spi_blacklist"); + tmp = extract_programmer_param_str(NULL, "spi_blacklist"); if (tmp) { i = strlen(tmp); if (!strncmp(tmp, "0x", 2)) { @@ -1036,7 +1036,7 @@ } free(tmp); - tmp = extract_programmer_param_str("spi_ignorelist"); + tmp = extract_programmer_param_str(NULL, "spi_ignorelist"); if (tmp) { i = strlen(tmp); if (!strncmp(tmp, "0x", 2)) { @@ -1073,7 +1073,7 @@ free(tmp); /* frequency to emulate in Hz (default), KHz, or MHz */ - tmp = extract_programmer_param_str("freq"); + tmp = extract_programmer_param_str(NULL, "freq"); if (tmp) { unsigned long int freq; char *units = tmp; @@ -1123,7 +1123,7 @@ } free(tmp); - tmp = extract_programmer_param_str("size"); + tmp = extract_programmer_param_str(NULL, "size"); if (tmp) { size = strtol(tmp, NULL, 10); if (size <= 0 || (size % 1024 != 0)) { @@ -1135,7 +1135,7 @@ free(tmp); } - tmp = extract_programmer_param_str("hwwp"); + tmp = extract_programmer_param_str(NULL, "hwwp"); if (tmp) { if (!strcmp(tmp, "yes")) { msg_pdbg("Emulated chip will have hardware WP enabled\n"); @@ -1150,7 +1150,7 @@ free(tmp); } - tmp = extract_programmer_param_str("emulate"); + tmp = extract_programmer_param_str(NULL, "emulate"); if (!tmp) { if (size != -1) { msg_perr("%s: size parameter is only valid for VARIABLE_SIZE chip.\n", __func__); @@ -1274,7 +1274,7 @@ free(tmp); /* Should emulated flash erase to zero (yes/no)? */ - tmp = extract_programmer_param_str("erase_to_zero"); + tmp = extract_programmer_param_str(NULL, "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__); @@ -1294,7 +1294,7 @@ } free(tmp); - status = extract_programmer_param_str("spi_status"); + status = extract_programmer_param_str(NULL, "spi_status"); if (status) { unsigned int emu_status; @@ -1370,7 +1370,7 @@ 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("image"); + data->emu_persistent_image = extract_programmer_param_str(NULL, "image"); if (!data->emu_persistent_image) { /* Nothing else to do. */ goto dummy_init_out; diff --git a/flashrom.c b/flashrom.c index ba363b2..5b7bbbd 100644 --- a/flashrom.c +++ b/flashrom.c @@ -66,6 +66,10 @@ /* Did we change something or was every erase/write skipped (if any)? */ static bool all_skipped = true; +struct programmer_cfg { + char *params; +}; + /* Register a function to be executed on programmer shutdown. * The advantage over atexit() is that you can supply a void pointer which will * be used as parameter to the registered function upon programmer shutdown. @@ -278,7 +282,7 @@ return opt; } -char *extract_programmer_param_str(const char *param_name) +char *extract_programmer_param_str(const struct programmer_cfg *cfg, const char *param_name) { return extract_param(&programmer_param, param_name, ","); } diff --git a/ft2232_spi.c b/ft2232_spi.c index bbacc03..7c31013 100644 --- a/ft2232_spi.c +++ b/ft2232_spi.c @@ -340,7 +340,7 @@ struct ftdi_context ftdic; struct ft2232_data *spi_data; - arg = extract_programmer_param_str("type"); + arg = extract_programmer_param_str(NULL, "type"); if (arg) { if (!strcasecmp(arg, "2232H")) { ft2232_type = FTDI_FT2232H_PID; @@ -447,7 +447,7 @@ /* Remember reserved pins before pindir gets modified. */ const uint8_t rsv_bits = pindir & 0xf0; - arg = extract_programmer_param_str("port"); + arg = extract_programmer_param_str(NULL, "port"); if (arg) { switch (toupper((unsigned char)*arg)) { case 'A': @@ -480,7 +480,7 @@ } free(arg); - arg = extract_programmer_param_str("divisor"); + arg = extract_programmer_param_str(NULL, "divisor"); if (arg && strlen(arg)) { unsigned int temp = 0; char *endptr; @@ -496,7 +496,7 @@ free(arg); bool csgpiol_set = false; - arg = extract_programmer_param_str("csgpiol"); + arg = extract_programmer_param_str(NULL, "csgpiol"); if (arg) { csgpiol_set = true; msg_pwarn("Deprecation warning: `csgpiol` is deprecated and will be removed " @@ -529,7 +529,7 @@ 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(gpiol_param); + arg = extract_programmer_param_str(NULL, gpiol_param); if (!arg) continue; @@ -602,8 +602,8 @@ msg_perr("Unable to select channel (%s).\n", ftdi_get_error_string(&ftdic)); } - arg = extract_programmer_param_str("serial"); - arg2 = extract_programmer_param_str("description"); + arg = extract_programmer_param_str(NULL, "serial"); + arg2 = extract_programmer_param_str(NULL, "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 f527c4e..29fdfd4 100644 --- a/i2c_helper_linux.c +++ b/i2c_helper_linux.c @@ -100,8 +100,8 @@ { int fd = -1; - char *bus_str = extract_programmer_param_str("bus"); - char *device_path = extract_programmer_param_str("devpath"); + char *bus_str = extract_programmer_param_str(NULL, "bus"); + char *device_path = extract_programmer_param_str(NULL, "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/ichspi.c b/ichspi.c index 030cd92..78c446f 100644 --- a/ichspi.c +++ b/ichspi.c @@ -1874,7 +1874,7 @@ static int get_ich_spi_mode_param(enum ich_spi_mode *ich_spi_mode) { - char *const arg = extract_programmer_param_str("ich_spi_mode"); + char *const arg = extract_programmer_param_str(NULL, "ich_spi_mode"); if (!arg) { return 0; } else if (!strcmp(arg, "hwseq")) { diff --git a/include/programmer.h b/include/programmer.h index f5ce556..c58459f 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -29,6 +29,7 @@ USB, OTHER, }; +struct programmer_cfg; struct dev_entry { uint16_t vendor_id; @@ -287,7 +288,7 @@ extern int programmer_may_write; extern unsigned long flashbase; unsigned int count_max_decode_exceedings(const struct flashctx *flash); -char *extract_programmer_param_str(const char *param_name); +char *extract_programmer_param_str(const struct programmer_cfg *cfg, const char *param_name); /* spi.c */ #define MAX_DATA_UNSPECIFIED 0 diff --git a/internal.c b/internal.c index 57412a2..8e267cd 100644 --- a/internal.c +++ b/internal.c @@ -128,7 +128,7 @@ *board_vendor = NULL; *board_model = NULL; - arg = extract_programmer_param_str("boardenable"); + arg = extract_programmer_param_str(NULL, "boardenable"); if (arg && !strcmp(arg,"force")) { *boardenable = 1; } else if (arg && !strlen(arg)) { @@ -142,7 +142,7 @@ } free(arg); - arg = extract_programmer_param_str("boardmismatch"); + arg = extract_programmer_param_str(NULL, "boardmismatch"); if (arg && !strcmp(arg,"force")) { *boardmismatch = 1; } else if (arg && !strlen(arg)) { @@ -156,7 +156,7 @@ } free(arg); - arg = extract_programmer_param_str("laptop"); + arg = extract_programmer_param_str(NULL, "laptop"); if (arg && !strcmp(arg, "force_I_want_a_brick")) *force_laptop = 1; else if (arg && !strcmp(arg, "this_is_not_a_laptop")) @@ -172,7 +172,7 @@ } free(arg); - arg = extract_programmer_param_str("mainboard"); + arg = extract_programmer_param_str(NULL, "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 56a85f2..568d714 100644 --- a/it87spi.c +++ b/it87spi.c @@ -328,7 +328,7 @@ enter_conf_mode_ite(port); - char *param = extract_programmer_param_str("dualbiosindex"); + char *param = extract_programmer_param_str(NULL, "dualbiosindex"); if (param != NULL) { sio_write(port, 0x07, 0x07); /* Select GPIO LDN */ tmp = sio_read(port, 0xEF); @@ -394,7 +394,7 @@ flashport |= sio_read(port, 0x65); msg_pdbg("Serial flash port 0x%04x\n", flashport); /* Non-default port requested? */ - param = extract_programmer_param_str("it87spiport"); + param = extract_programmer_param_str(NULL, "it87spiport"); if (param) { char *endptr = NULL; unsigned long forced_flashport; diff --git a/jlink_spi.c b/jlink_spi.c index deab8da..eba8dbc 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -203,7 +203,7 @@ struct jlink_spi_data *jlink_data = NULL; bool enable_target_power; - arg = extract_programmer_param_str("spispeed"); + arg = extract_programmer_param_str(NULL, "spispeed"); if (arg) { char *endptr; @@ -230,7 +230,7 @@ bool use_serial_number; uint32_t serial_number; - arg = extract_programmer_param_str("serial"); + arg = extract_programmer_param_str(NULL, "serial"); if (arg) { if (!strlen(arg)) { @@ -259,7 +259,7 @@ free(arg); reset_cs = true; - arg = extract_programmer_param_str("cs"); + arg = extract_programmer_param_str(NULL, "cs"); if (arg) { if (!strcasecmp(arg, "reset")) { @@ -281,7 +281,7 @@ msg_pdbg("Using TRST as chip select signal.\n"); enable_target_power = false; - arg = extract_programmer_param_str("power"); + arg = extract_programmer_param_str(NULL, "power"); if (arg) { if (!strcasecmp(arg, "on")) { diff --git a/linux_mtd.c b/linux_mtd.c index dd86466..414a6b4 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -500,7 +500,7 @@ int ret = 1; struct linux_mtd_data *data = NULL; - param_str = extract_programmer_param_str("dev"); + param_str = extract_programmer_param_str(NULL, "dev"); if (param_str) { char *endptr; diff --git a/linux_spi.c b/linux_spi.c index 6ed4f68..cef7909 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -177,7 +177,7 @@ size_t max_kernel_buf_size; struct linux_spi_data *spi_data; - param_str = extract_programmer_param_str("spispeed"); + param_str = extract_programmer_param_str(NULL, "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 @@ } free(param_str); - param_str = extract_programmer_param_str("dev"); + param_str = extract_programmer_param_str(NULL, "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 4929fbf..4133edb 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -470,7 +470,7 @@ int ret = 0; *allow_brick = false; /* Default behaviour is to bail. */ - brick_str = extract_programmer_param_str("allow_brick"); + brick_str = extract_programmer_param_str(NULL, "allow_brick"); if (brick_str) { if (!strcmp(brick_str, "yes")) { *allow_brick = true; diff --git a/mstarddc_spi.c b/mstarddc_spi.c index c59f943..50a75d3 100644 --- a/mstarddc_spi.c +++ b/mstarddc_spi.c @@ -159,7 +159,7 @@ struct mstarddc_spi_data *mstarddc_data; // Get device, address from command-line - char *i2c_device = extract_programmer_param_str("dev"); + char *i2c_device = extract_programmer_param_str(NULL, "dev"); if (i2c_device != NULL && strlen(i2c_device) > 0) { char *i2c_address = strchr(i2c_device, ':'); if (i2c_address != NULL) { @@ -182,7 +182,7 @@ 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("noreset"); + char *noreset = extract_programmer_param_str(NULL, "noreset"); if (noreset != NULL && noreset[0] == '1') mstarddc_doreset = 0; free(noreset); diff --git a/ni845x_spi.c b/ni845x_spi.c index 14bebce..f75c399 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -553,7 +553,7 @@ int32 tmp = 0; // read the cs parameter (which Chip select should we use) - CS_str = extract_programmer_param_str("cs"); + CS_str = extract_programmer_param_str(NULL, "cs"); if (CS_str) { CS_number = CS_str[0] - '0'; free(CS_str); @@ -563,7 +563,7 @@ } } - voltage = extract_programmer_param_str("voltage"); + voltage = extract_programmer_param_str(NULL, "voltage"); if (voltage != NULL) { requested_io_voltage_mV = parse_voltage(voltage); free(voltage); @@ -571,9 +571,9 @@ return 1; } - serial_number = extract_programmer_param_str("serial"); + serial_number = extract_programmer_param_str(NULL, "serial"); - speed_str = extract_programmer_param_str("spispeed"); + speed_str = extract_programmer_param_str(NULL, "spispeed"); if (speed_str) { spi_speed_KHz = strtoul(speed_str, &endptr, 0); if (*endptr) { @@ -586,7 +586,7 @@ } ignore_io_voltage_limits = false; - ignore_io_voltage_limits_str = extract_programmer_param_str("ignore_io_voltage_limits"); + ignore_io_voltage_limits_str = extract_programmer_param_str(NULL, "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 27622a6..b3c404c 100644 --- a/ogp_spi.c +++ b/ogp_spi.c @@ -117,7 +117,7 @@ uint32_t ogp_reg__ce; uint32_t ogp_reg_sck; - type = extract_programmer_param_str("rom"); + type = extract_programmer_param_str(NULL, "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 e2d2862..815f398 100644 --- a/parade_lspcon.c +++ b/parade_lspcon.c @@ -446,7 +446,7 @@ int ret = 0; *allow_brick = false; /* Default behaviour is to bail. */ - brick_str = extract_programmer_param_str("allow_brick"); + brick_str = extract_programmer_param_str(NULL, "allow_brick"); if (brick_str) { if (!strcmp(brick_str, "yes")) { *allow_brick = true; diff --git a/pcidev.c b/pcidev.c index 643b0cd..2fbc1e5 100644 --- a/pcidev.c +++ b/pcidev.c @@ -272,7 +272,7 @@ pci_filter_init(pacc, &filter); /* Filter by bb:dd.f (if supplied by the user). */ - pcidev_bdf = extract_programmer_param_str("pci"); + pcidev_bdf = extract_programmer_param_str(NULL, "pci"); 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 9e34a58..7c84d96 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -412,7 +412,7 @@ int spispeed_idx = 0; char *param_str; - param_str = extract_programmer_param_str("spispeed"); + param_str = extract_programmer_param_str(NULL, "spispeed"); if (param_str != NULL) { int i = 0; for (; spispeeds[i].name; i++) { @@ -430,7 +430,7 @@ } int millivolt = 3500; - param_str = extract_programmer_param_str("voltage"); + param_str = extract_programmer_param_str(NULL, "voltage"); if (param_str != NULL) { millivolt = parse_voltage(param_str); free(param_str); diff --git a/pony_spi.c b/pony_spi.c index 60925e5..50f44da 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -130,7 +130,7 @@ *have_device = 0; /* The parameter is in format "dev=/dev/device,type=serbang" */ - arg = extract_programmer_param_str("dev"); + arg = extract_programmer_param_str(NULL, "dev"); if (arg && strlen(arg)) { sp_fd = sp_openserport(arg, 9600); if (sp_fd == SER_INV_FD) @@ -140,7 +140,7 @@ } free(arg); - arg = extract_programmer_param_str("type"); + arg = extract_programmer_param_str(NULL, "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 a291f96..3382b9e 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1432,7 +1432,7 @@ static int get_ap_request_type(void) { int ap_request = RAIDEN_DEBUG_SPI_REQ_ENABLE_AP; - char *custom_rst_str = extract_programmer_param_str("custom_rst"); + char *custom_rst_str = extract_programmer_param_str(NULL, "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 @@ */ int request_enable = RAIDEN_DEBUG_SPI_REQ_ENABLE; - char *target_str = extract_programmer_param_str("target"); + char *target_str = extract_programmer_param_str(NULL, "target"); if (target_str) { if (!strcasecmp(target_str, "ap")) request_enable = get_ap_request_type(); @@ -1485,7 +1485,7 @@ static int raiden_debug_spi_init(void) { struct usb_match match; - char *serial = extract_programmer_param_str("serial"); + char *serial = extract_programmer_param_str(NULL, "serial"); struct usb_device *current; struct usb_device *device = NULL; int found = 0; diff --git a/rayer_spi.c b/rayer_spi.c index 3d626b2..82c49b3 100644 --- a/rayer_spi.c +++ b/rayer_spi.c @@ -244,7 +244,7 @@ uint8_t lpt_outbyte; /* Non-default port requested? */ - arg = extract_programmer_param_str("iobase"); + arg = extract_programmer_param_str(NULL, "iobase"); if (arg) { char *endptr = NULL; unsigned long tmp; @@ -277,7 +277,7 @@ msg_pdbg("Using address 0x%x as I/O base for parallel port access.\n", lpt_iobase); - arg = extract_programmer_param_str("type"); + arg = extract_programmer_param_str(NULL, "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 8d4f86d..6c2b86f 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -450,7 +450,7 @@ int ret = 0; *allow_brick = false; /* Default behaviour is to bail. */ - param_str = extract_programmer_param_str("allow_brick"); + param_str = extract_programmer_param_str(NULL, "allow_brick"); if (param_str) { if (!strcmp(param_str, "yes")) { *allow_brick = true; @@ -462,7 +462,7 @@ free(param_str); *reset = false; /* Default behaviour is no MCU reset on tear-down. */ - param_str = extract_programmer_param_str("reset_mcu"); + param_str = extract_programmer_param_str(NULL, "reset_mcu"); if (param_str) { if (param_str[0] == '1') { *reset = true; @@ -476,7 +476,7 @@ free(param_str); *enter_isp = true; /* Default behaviour is enter ISP on setup. */ - param_str = extract_programmer_param_str("enter_isp"); + param_str = extract_programmer_param_str(NULL, "enter_isp"); if (param_str) { if (param_str[0] == '1') { *enter_isp = true; diff --git a/sb600spi.c b/sb600spi.c index f218ca6..df8d726 100644 --- a/sb600spi.c +++ b/sb600spi.c @@ -415,7 +415,7 @@ int16_t spireadmode_idx = -1; char *param_str; - param_str = extract_programmer_param_str("spispeed"); + param_str = extract_programmer_param_str(NULL, "spispeed"); if (param_str != NULL) { unsigned int i; for (i = 0; i < ARRAY_SIZE(spispeeds); i++) { @@ -439,7 +439,7 @@ free(param_str); } - param_str = extract_programmer_param_str("spireadmode"); + param_str = extract_programmer_param_str(NULL, "spireadmode"); if (param_str != NULL) { unsigned int i; for (i = 0; i < ARRAY_SIZE(spireadmodes); i++) { @@ -528,7 +528,7 @@ return 0; bool amd_imc_force = false; - char *param_value = extract_programmer_param_str("amd_imc_force"); + char *param_value = extract_programmer_param_str(NULL, "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 ca3a94e..4480285 100644 --- a/serprog.c +++ b/serprog.c @@ -574,7 +574,7 @@ int have_device = 0; /* the parameter is either of format "dev=/dev/device[:baud]" or "ip=ip:port" */ - device = extract_programmer_param_str("dev"); + device = extract_programmer_param_str(NULL, "dev"); if (device && strlen(device)) { char *baud_str = strstr(device, ":"); if (baud_str != NULL) { @@ -611,7 +611,7 @@ } free(device); - device = extract_programmer_param_str("ip"); + device = extract_programmer_param_str(NULL, "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 @@ spi_master_serprog.max_data_read = v; msg_pdbg(MSGHEADER "Maximum read-n length is %d\n", v); } - spispeed = extract_programmer_param_str("spispeed"); + spispeed = extract_programmer_param_str(NULL, "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 22a0a06..ccba1d9 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -490,7 +490,7 @@ return 1; } - param_str = extract_programmer_param_str("serial"); + param_str = extract_programmer_param_str(NULL, "serial"); if (param_str) msg_pdbg("Opening STLINK-V3 with serial: %s\n", param_str); @@ -515,7 +515,7 @@ } free(param_str); - param_str = extract_programmer_param_str("spispeed"); + param_str = extract_programmer_param_str(NULL, "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 b3b44c4..3869bbf 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(parameter); + char *string = extract_programmer_param_str(NULL, parameter); match->name = parameter; -- To view, visit
https://review.coreboot.org/c/flashrom/+/66654
To unsubscribe, or for help writing mail filters, visit
https://review.coreboot.org/settings
Gerrit-Project: flashrom Gerrit-Branch: master Gerrit-Change-Id: I781a328fa280e0a9601050dd99a75af72c39c899 Gerrit-Change-Number: 66654 Gerrit-PatchSet: 6 Gerrit-Owner: Edward O'Callaghan <quasisec(a)chromium.org> Gerrit-Reviewer: Anastasia Klimchuk <aklm(a)chromium.org> Gerrit-Reviewer: Felix Singer <felixsinger(a)posteo.net> Gerrit-Reviewer: Nico Huber <nico.h(a)gmx.de> Gerrit-Reviewer: Nikolai Artemiev <nartemiev(a)google.com> Gerrit-Reviewer: Peter Marheine <pmarheine(a)chromium.org> Gerrit-Reviewer: build bot (Jenkins) <no-reply(a)coreboot.org> Gerrit-CC: Alexander Goncharov <chat(a)joursoir.net> Gerrit-MessageType: merged
1
0
0
0
← Newer
1
...
94
95
96
97
98
99
100
...
125
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Results per page:
10
25
50
100
200