Edward O'Callaghan has uploaded this change for review. ( https://review.coreboot.org/c/flashrom/+/72815 )
Change subject: tree/: Pass flashprog down to drv init() entry-points ......................................................................
tree/: Pass flashprog down to drv init() entry-points
Note, linux_mtd specialisation path fixed for new func signatures.
Change-Id: I482340ac43381ad4cb5c8544545222fdb9fe83ed Signed-off-by: Edward O'Callaghan quasisec@google.com --- 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 dirtyjtag_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 41 files changed, 57 insertions(+), 44 deletions(-)
git pull ssh://review.coreboot.org:29418/flashrom refs/changes/15/72815/1
diff --git a/atahpt.c b/atahpt.c index 71fd4d5..43a10ad 100644 --- a/atahpt.c +++ b/atahpt.c @@ -78,7 +78,7 @@ .shutdown = atahpt_shutdown, };
-static int atahpt_init(const struct programmer_cfg *cfg) +static int atahpt_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t io_base_addr; diff --git a/atapromise.c b/atapromise.c index 9beebf1..9deed47 100644 --- a/atapromise.c +++ b/atapromise.c @@ -117,7 +117,7 @@ .shutdown = atapromise_shutdown, };
-static int atapromise_init(const struct programmer_cfg *cfg) +static int atapromise_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t io_base_addr; diff --git a/atavia.c b/atavia.c index f35771a..92ac261 100644 --- a/atavia.c +++ b/atavia.c @@ -138,7 +138,7 @@ .chip_writeb = atavia_chip_writeb, };
-static int atavia_init(const struct programmer_cfg *cfg) +static int atavia_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { char *arg = extract_programmer_param_str(cfg, "offset"); if (arg) { diff --git a/buspirate_spi.c b/buspirate_spi.c index a40fb70..68cea11 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(const struct programmer_cfg *cfg) +static int buspirate_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { char *tmp; char *dev; diff --git a/ch341a_spi.c b/ch341a_spi.c index 75eaf86..c2b3943 100644 --- a/ch341a_spi.c +++ b/ch341a_spi.c @@ -421,7 +421,7 @@ .delay = ch341a_spi_delay, };
-static int ch341a_spi_init(const struct programmer_cfg *cfg) +static int ch341a_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { if (handle != NULL) { msg_cerr("%s: handle already set! Please report a bug at flashrom@flashrom.org\n", __func__); diff --git a/dediprog.c b/dediprog.c index 723f4a8..51529e9 100644 --- a/dediprog.c +++ b/dediprog.c @@ -1076,7 +1076,7 @@ return 0; }
-static int dediprog_init(const struct programmer_cfg *cfg) +static int dediprog_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { char *param_str; int spispeed_idx = 1; diff --git a/developerbox_spi.c b/developerbox_spi.c index 64b7e8a..0729117 100644 --- a/developerbox_spi.c +++ b/developerbox_spi.c @@ -142,7 +142,7 @@ return 0; }
-static int developerbox_spi_init(const struct programmer_cfg *cfg) +static int developerbox_spi_init(struct flashrom_programmer *flashprog, 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 55cb6ec..4545d1c 100644 --- a/digilent_spi.c +++ b/digilent_spi.c @@ -373,7 +373,7 @@ { NULL, 0 }, };
-static int digilent_spi_init(const struct programmer_cfg *cfg) +static int digilent_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { char *param_str; uint32_t speed_hz = spispeeds[0].speed; diff --git a/dirtyjtag_spi.c b/dirtyjtag_spi.c index 42169ed..e822217 100644 --- a/dirtyjtag_spi.c +++ b/dirtyjtag_spi.c @@ -201,7 +201,7 @@ .probe_opcode = default_spi_probe_opcode, };
-static int dirtyjtag_spi_init(const struct programmer_cfg *cfg) +static int dirtyjtag_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct libusb_device_handle *handle = NULL; struct dirtyjtag_spi_data *djtag_data = NULL; diff --git a/drkaiser.c b/drkaiser.c index ebf5119..2e5dd1a 100644 --- a/drkaiser.c +++ b/drkaiser.c @@ -75,7 +75,7 @@ .shutdown = drkaiser_shutdown, };
-static int drkaiser_init(const struct programmer_cfg *cfg) +static int drkaiser_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t addr; diff --git a/dummyflasher.c b/dummyflasher.c index 2bdd10c..149811c 100644 --- a/dummyflasher.c +++ b/dummyflasher.c @@ -1350,7 +1350,7 @@ return 0; }
-static int dummy_init(const struct programmer_cfg *cfg) +static int dummy_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { int ret = 0; struct stat image_stat; diff --git a/flashrom.c b/flashrom.c index a0754e6..20f7b43 100644 --- a/flashrom.c +++ b/flashrom.c @@ -159,7 +159,7 @@ }
msg_pdbg("Initializing %s programmer\n", prog->name); - ret = prog->init(&cfg); + ret = prog->init(*flashprog, &cfg); if (cfg.params && strlen(cfg.params)) { 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 dfec1a0..685963d 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(const struct programmer_cfg *cfg) +static int ft2232_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { int ret = 0; unsigned char buf[512]; diff --git a/gfxnvidia.c b/gfxnvidia.c index b420975..7d8eb59 100644 --- a/gfxnvidia.c +++ b/gfxnvidia.c @@ -100,7 +100,7 @@ .shutdown = gfxnvidia_shutdown, };
-static int gfxnvidia_init(const struct programmer_cfg *cfg) +static int gfxnvidia_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t reg32; diff --git a/include/programmer.h b/include/programmer.h index 233a6fe..712aee6 100644 --- a/include/programmer.h +++ b/include/programmer.h @@ -48,7 +48,7 @@ const char *const note; } devs;
- int (*init) (const struct programmer_cfg *cfg); + int (*init) (struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg); };
extern const struct programmer_entry *const programmer_table[]; @@ -375,10 +375,10 @@ int init_superio_ite(const struct programmer_cfg *cfg);
/* trivial wrapper to avoid cluttering internal_init() with #if */ -static inline int try_mtd(const struct programmer_cfg *cfg) +static inline int try_mtd(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { #if CONFIG_LINUX_MTD == 1 - return programmer_linux_mtd.init(cfg); + return programmer_linux_mtd.init(flashprog, cfg); #else return 1; #endif diff --git a/internal.c b/internal.c index c5fdb74..c096475 100644 --- a/internal.c +++ b/internal.c @@ -162,7 +162,7 @@ return 0; }
-static int internal_init(const struct programmer_cfg *cfg) +static int internal_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { int ret = 0; bool force_laptop; @@ -191,7 +191,7 @@ */ internal_buses_supported = BUS_NONSPI;
- if (try_mtd(cfg) == 0) { + if (try_mtd(flashprog, cfg) == 0) { ret = 0; goto internal_init_exit; } diff --git a/it8212.c b/it8212.c index 3c1161d..2450454 100644 --- a/it8212.c +++ b/it8212.c @@ -68,7 +68,7 @@ .shutdown = it8212_shutdown, };
-static int it8212_init(const struct programmer_cfg *cfg) +static int it8212_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { uint8_t *bar;
diff --git a/jlink_spi.c b/jlink_spi.c index ad2ca78..86bdb6a 100644 --- a/jlink_spi.c +++ b/jlink_spi.c @@ -192,7 +192,7 @@ .probe_opcode = default_spi_probe_opcode, };
-static int jlink_spi_init(const struct programmer_cfg *cfg) +static int jlink_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { char *arg; unsigned long speed = 0; diff --git a/linux_mtd.c b/linux_mtd.c index 495db9a..0e68cc7 100644 --- a/linux_mtd.c +++ b/linux_mtd.c @@ -494,7 +494,7 @@ return ret; }
-static int linux_mtd_init(const struct programmer_cfg *cfg) +static int linux_mtd_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { char *param_str; int dev_num = 0; diff --git a/linux_spi.c b/linux_spi.c index d65b3e8..40f2532 100644 --- a/linux_spi.c +++ b/linux_spi.c @@ -164,7 +164,7 @@ return result; }
-static int linux_spi_init(const struct programmer_cfg *cfg) +static int linux_spi_init(struct flashrom_programmer *flashprog, 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 c15df05..5f1321b 100644 --- a/mediatek_i2c_spi.c +++ b/mediatek_i2c_spi.c @@ -483,7 +483,7 @@ return ret; }
-static int mediatek_init(const struct programmer_cfg *cfg) +static int mediatek_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { int ret; bool allow_brick; diff --git a/mstarddc_spi.c b/mstarddc_spi.c index bd65281..e94eb3b 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(const struct programmer_cfg *cfg) +static int mstarddc_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { int ret = 0; int mstarddc_fd = -1; diff --git a/ni845x_spi.c b/ni845x_spi.c index fd5057d..0193134 100644 --- a/ni845x_spi.c +++ b/ni845x_spi.c @@ -539,7 +539,7 @@ .probe_opcode = default_spi_probe_opcode, };
-static int ni845x_spi_init(const struct programmer_cfg *cfg) +static int ni845x_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { char *speed_str = NULL; char *CS_str = NULL; diff --git a/nic3com.c b/nic3com.c index a578d48..8ca79ae 100644 --- a/nic3com.c +++ b/nic3com.c @@ -95,7 +95,7 @@ .shutdown = nic3com_shutdown, };
-static int nic3com_init(const struct programmer_cfg *cfg) +static int nic3com_init(struct flashrom_programmer *flashprog, 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 feb07b6..0e19856 100644 --- a/nicintel.c +++ b/nicintel.c @@ -71,7 +71,7 @@ .shutdown = nicintel_shutdown, };
-static int nicintel_init(const struct programmer_cfg *cfg) +static int nicintel_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uintptr_t addr; diff --git a/nicintel_eeprom.c b/nicintel_eeprom.c index 80ccd88..2a7861c 100644 --- a/nicintel_eeprom.c +++ b/nicintel_eeprom.c @@ -479,7 +479,7 @@ .shutdown = nicintel_ee_shutdown_i210, };
-static int nicintel_ee_init(const struct programmer_cfg *cfg) +static int nicintel_ee_init(struct flashrom_programmer *flashprog, 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 2821d23..a3d1b1c 100644 --- a/nicintel_spi.c +++ b/nicintel_spi.c @@ -285,7 +285,7 @@ return 0; }
-static int nicintel_spi_init(const struct programmer_cfg *cfg) +static int nicintel_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL;
diff --git a/nicnatsemi.c b/nicnatsemi.c index 65377dc..817855e 100644 --- a/nicnatsemi.c +++ b/nicnatsemi.c @@ -82,7 +82,7 @@ .shutdown = nicnatsemi_shutdown, };
-static int nicnatsemi_init(const struct programmer_cfg *cfg) +static int nicnatsemi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t io_base_addr; diff --git a/nicrealtek.c b/nicrealtek.c index 5937e35..d2c7850 100644 --- a/nicrealtek.c +++ b/nicrealtek.c @@ -91,7 +91,7 @@ .shutdown = nicrealtek_shutdown, };
-static int nicrealtek_init(const struct programmer_cfg *cfg) +static int nicrealtek_init(struct flashrom_programmer *flashprog, 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 d85c823..2dcc5ea 100644 --- a/ogp_spi.c +++ b/ogp_spi.c @@ -107,7 +107,7 @@ return 0; }
-static int ogp_spi_init(const struct programmer_cfg *cfg) +static int ogp_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; char *type; diff --git a/parade_lspcon.c b/parade_lspcon.c index a50346e..ded8453 100644 --- a/parade_lspcon.c +++ b/parade_lspcon.c @@ -460,7 +460,7 @@ return ret; }
-static int parade_lspcon_init(const struct programmer_cfg *cfg) +static int parade_lspcon_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { bool allow_brick;
diff --git a/pickit2_spi.c b/pickit2_spi.c index 86c5403..10695c7 100644 --- a/pickit2_spi.c +++ b/pickit2_spi.c @@ -387,7 +387,7 @@ .probe_opcode = default_spi_probe_opcode, };
-static int pickit2_spi_init(const struct programmer_cfg *cfg) +static int pickit2_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { uint8_t buf[CMD_LENGTH] = { CMD_EXEC_SCRIPT, diff --git a/pony_spi.c b/pony_spi.c index 0647f91..1869d21 100644 --- a/pony_spi.c +++ b/pony_spi.c @@ -160,7 +160,7 @@ return ret; }
-static int pony_spi_init(const struct programmer_cfg *cfg) +static int pony_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { int i, data_out; enum pony_type type; diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c index d1a09d7..f604c75 100644 --- a/raiden_debug_spi.c +++ b/raiden_debug_spi.c @@ -1486,7 +1486,7 @@ dev = usb_device_free(dev); }
-static int raiden_debug_spi_init(const struct programmer_cfg *cfg) +static int raiden_debug_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct usb_match match; char *serial = extract_programmer_param_str(cfg, "serial"); diff --git a/rayer_spi.c b/rayer_spi.c index 27caf2b..e0f37d1 100644 --- a/rayer_spi.c +++ b/rayer_spi.c @@ -296,7 +296,7 @@ return *prog ? 0 : -1; }
-static int rayer_spi_init(const struct programmer_cfg *cfg) +static int rayer_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { const struct rayer_programmer *prog; struct rayer_pinout *pinout = NULL; diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c index 2a5d5ed..6bfe536 100644 --- a/realtek_mst_i2c_spi.c +++ b/realtek_mst_i2c_spi.c @@ -492,7 +492,7 @@ return ret; }
-static int realtek_mst_i2c_spi_init(const struct programmer_cfg *cfg) +static int realtek_mst_i2c_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { int ret = 0; bool reset, enter_isp, allow_brick; diff --git a/satamv.c b/satamv.c index fea4c2b..0aee07f 100644 --- a/satamv.c +++ b/satamv.c @@ -108,7 +108,7 @@ * 0xc08 PCI BAR2 (Flash/NVRAM) Control * 0x1046c Flash Parameters */ -static int satamv_init(const struct programmer_cfg *cfg) +static int satamv_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uintptr_t addr; diff --git a/satasii.c b/satasii.c index e881f96..4e6b7de 100644 --- a/satasii.c +++ b/satasii.c @@ -99,7 +99,7 @@ .shutdown = satasii_shutdown, };
-static int satasii_init(const struct programmer_cfg *cfg) +static int satasii_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { struct pci_dev *dev = NULL; uint32_t addr; diff --git a/serprog.c b/serprog.c index 5ddbe3d..2b1b7f1 100644 --- a/serprog.c +++ b/serprog.c @@ -601,7 +601,7 @@
static enum chipbustype serprog_buses_supported = BUS_NONE;
-static int serprog_init(const struct programmer_cfg *cfg) +static int serprog_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { uint16_t iface; unsigned char pgmname[17]; diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c index 16a66b4..578e041 100644 --- a/stlinkv3_spi.c +++ b/stlinkv3_spi.c @@ -473,7 +473,7 @@ .probe_opcode = default_spi_probe_opcode, };
-static int stlinkv3_spi_init(const struct programmer_cfg *cfg) +static int stlinkv3_spi_init(struct flashrom_programmer *flashprog, 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 75d5be7..a64a694 100644 --- a/usbblaster_spi.c +++ b/usbblaster_spi.c @@ -176,7 +176,7 @@ };
/* Returns 0 upon success, a negative number upon errors. */ -static int usbblaster_spi_init(const struct programmer_cfg *cfg) +static int usbblaster_spi_init(struct flashrom_programmer *flashprog, const struct programmer_cfg *cfg) { uint8_t buf[BUF_SIZE + 1] = { 0 }; struct ftdi_context ftdic;