mirror of
https://review.coreboot.org/flashrom.git
synced 2025-04-26 22:52:34 +02:00
tree/: Drop default_spi_probe_opcode for NULL case
A NULL func pointer is necessary and sufficient for the condition `NULL func pointer => true' as to not need this boilerplate as it implies default behaviour of a supported opcode within the `check_block_eraser()` match supported loop. Ran; ``` $ find . -name '*.[c,h]' -exec sed -i '/.probe_opcode = default_spi_probe_opcode,/d' '{}' \; ``` Change-Id: Id502c5d2596ad1db52faf05723083620e4c52c12 Signed-off-by: Edward O'Callaghan <quasisec@google.com> Reviewed-on: https://review.coreboot.org/c/flashrom/+/70264 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Thomas Heijligen <src@posteo.de> Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
This commit is contained in:
parent
c66d2bd1ca
commit
e1f30bbce7
@ -125,7 +125,6 @@ static const struct spi_master asm106x_spi_master = {
|
||||
.shutdown = asm106x_shutdown,
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int asm106x_init(const struct programmer_cfg *cfg)
|
||||
|
@ -146,7 +146,6 @@ static const struct spi_master spi_master_bitbang = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = bitbang_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data)
|
||||
|
@ -181,7 +181,6 @@ static struct spi_master spi_master_buspirate = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = buspirate_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static const struct buspirate_speeds spispeeds[] = {
|
||||
|
@ -416,7 +416,6 @@ static const struct spi_master spi_master_ch341a_spi = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = ch341a_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
.delay = ch341a_spi_delay,
|
||||
};
|
||||
|
||||
|
@ -257,7 +257,6 @@ static const struct spi_master spi_master_ch347_spi = {
|
||||
.write_256 = default_spi_write_256,
|
||||
.write_aai = default_spi_write_aai,
|
||||
.shutdown = ch347_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
/* Largely copied from ch341a_spi.c */
|
||||
|
@ -1038,7 +1038,6 @@ static struct spi_master spi_master_dediprog = {
|
||||
.write_256 = dediprog_spi_write_256,
|
||||
.write_aai = dediprog_spi_write_aai,
|
||||
.shutdown = dediprog_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
/*
|
||||
|
@ -336,7 +336,6 @@ static const struct spi_master spi_master_digilent_spi = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = digilent_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static bool default_reset(struct libusb_device_handle *handle)
|
||||
|
@ -197,7 +197,6 @@ static const struct spi_master spi_master_dirtyjtag_spi = {
|
||||
.write_256 = default_spi_write_256,
|
||||
.write_aai = default_spi_write_aai,
|
||||
.shutdown = dirtyjtag_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int dirtyjtag_spi_init(const struct programmer_cfg *cfg)
|
||||
|
@ -470,7 +470,7 @@ int check_block_eraser(const struct flashctx *flash, int k, int log)
|
||||
if (flash->mst->buses_supported & BUS_SPI) {
|
||||
const uint8_t *opcode = spi_get_opcode_from_erasefn(eraser.block_erase);
|
||||
for (int i = 0; opcode[i]; i++) {
|
||||
if (!flash->mst->spi.probe_opcode(flash, opcode[i])) {
|
||||
if (!spi_probe_opcode(flash, opcode[i])) {
|
||||
if (log)
|
||||
msg_cdbg("block erase function and layout found "
|
||||
"but SPI master doesn't support the function. ");
|
||||
|
@ -299,7 +299,6 @@ static const struct spi_master spi_master_ft2232 = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = ft2232_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
/* Returns 0 upon success, a negative number upon errors. */
|
||||
|
@ -26,6 +26,7 @@
|
||||
int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int spi_chip_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int spi_chip_read(struct flashctx *flash, uint8_t *buf, unsigned int start, int unsigned len);
|
||||
bool spi_probe_opcode(const struct flashctx *flash, uint8_t opcode);
|
||||
|
||||
/* spi25.c */
|
||||
int probe_spi_rdid(struct flashctx *flash);
|
||||
|
@ -312,7 +312,7 @@ struct spi_master {
|
||||
int (*write_256)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int (*write_aai)(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int (*shutdown)(void *data);
|
||||
bool (*probe_opcode)(const struct flashctx *flash, uint8_t opcode);
|
||||
bool (*probe_opcode)(const struct flashctx *flash, uint8_t opcode); /* NULL func implies true. */
|
||||
void (*delay) (const struct flashctx *flash, unsigned int usecs);
|
||||
void (*get_region)(const struct flashctx *flash, unsigned int addr, struct flash_region *region);
|
||||
void *data;
|
||||
@ -321,7 +321,6 @@ struct spi_master {
|
||||
int default_spi_read(struct flashctx *flash, uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int default_spi_write_256(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
int default_spi_write_aai(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len);
|
||||
bool default_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode);
|
||||
int register_spi_master(const struct spi_master *mst, void *data);
|
||||
|
||||
/* The following enum is needed by ich_descriptor_tool and ich* code as well as in chipset_enable.c. */
|
||||
|
@ -320,7 +320,6 @@ static const struct spi_master spi_master_it87xx = {
|
||||
.write_256 = it8716f_spi_chip_write_256,
|
||||
.write_aai = spi_chip_write_1,
|
||||
.shutdown = it8716f_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static uint16_t it87spi_probe(const struct programmer_cfg *cfg, uint16_t port)
|
||||
|
@ -188,7 +188,6 @@ static const struct spi_master spi_master_jlink_spi = {
|
||||
.write_256 = default_spi_write_256,
|
||||
.features = SPI_MASTER_4BA,
|
||||
.shutdown = jlink_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int jlink_spi_init(const struct programmer_cfg *cfg)
|
||||
|
@ -119,7 +119,6 @@ static const struct spi_master spi_master_linux = {
|
||||
.read = linux_spi_read,
|
||||
.write_256 = linux_spi_write_256,
|
||||
.shutdown = linux_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
/* Read max buffer size from sysfs, or use page size as fallback. */
|
||||
|
@ -459,7 +459,6 @@ static const struct spi_master spi_master_i2c_mediatek = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = mediatek_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int get_params(const struct programmer_cfg *cfg, bool *allow_brick)
|
||||
|
@ -145,7 +145,6 @@ static const struct spi_master spi_master_mstarddc = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = mstarddc_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
/* Returns 0 upon success, a negative number upon errors. */
|
||||
|
@ -535,7 +535,6 @@ static const struct spi_master spi_programmer_ni845x = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = ni845x_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int ni845x_spi_init(const struct programmer_cfg *cfg)
|
||||
|
@ -436,7 +436,6 @@ static const struct spi_master spi_master_parade_lspcon = {
|
||||
.write_256 = parade_lspcon_write_256,
|
||||
.write_aai = parade_lspcon_write_aai,
|
||||
.shutdown = parade_lspcon_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int get_params(const struct programmer_cfg *cfg, bool *allow_brick)
|
||||
|
@ -383,7 +383,6 @@ static const struct spi_master spi_master_pickit2 = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = pickit2_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int pickit2_spi_init(const struct programmer_cfg *cfg)
|
||||
|
@ -1323,7 +1323,6 @@ static const struct spi_master spi_master_raiden_debug = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = raiden_debug_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int match_endpoint(struct libusb_endpoint_descriptor const *descriptor,
|
||||
|
@ -440,7 +440,6 @@ static const struct spi_master spi_master_i2c_realtek_mst = {
|
||||
.write_256 = realtek_mst_i2c_spi_write_256,
|
||||
.write_aai = realtek_mst_i2c_spi_write_aai,
|
||||
.shutdown = realtek_mst_i2c_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int get_params(const struct programmer_cfg *cfg, bool *reset, bool *enter_isp, bool *allow_brick)
|
||||
|
@ -604,7 +604,6 @@ static const struct spi_master spi_master_sb600 = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = sb600spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static const struct spi_master spi_master_yangtze = {
|
||||
@ -616,7 +615,6 @@ static const struct spi_master spi_master_yangtze = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = sb600spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static const struct spi_master spi_master_promontory = {
|
||||
@ -628,7 +626,6 @@ static const struct spi_master spi_master_promontory = {
|
||||
.read = promontory_read_memmapped,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = sb600spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
int sb600_probe_spi(const struct programmer_cfg *cfg, struct pci_dev *dev)
|
||||
|
@ -463,7 +463,6 @@ static struct spi_master spi_master_serprog = {
|
||||
.command = serprog_spi_send_command,
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
.delay = serprog_delay,
|
||||
};
|
||||
|
||||
|
9
spi.c
9
spi.c
@ -139,9 +139,11 @@ int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start
|
||||
return default_spi_write_aai(flash, buf, start, len);
|
||||
}
|
||||
|
||||
bool default_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode)
|
||||
bool spi_probe_opcode(const struct flashctx *flash, uint8_t opcode)
|
||||
{
|
||||
return true;
|
||||
if (!flash->mst->spi.probe_opcode)
|
||||
return true; /* no probe_opcode implies default of supported. */
|
||||
return flash->mst->spi.probe_opcode(flash, opcode);
|
||||
}
|
||||
|
||||
int register_spi_master(const struct spi_master *mst, void *data)
|
||||
@ -155,8 +157,7 @@ int register_spi_master(const struct spi_master *mst, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
if (!mst->write_256 || !mst->read || !mst->probe_opcode ||
|
||||
(!mst->command && !mst->multicommand)) {
|
||||
if (!mst->write_256 || !mst->read || (!mst->command && !mst->multicommand)) {
|
||||
msg_perr("%s called with incomplete master definition. "
|
||||
"Please report a bug at flashrom@flashrom.org\n",
|
||||
__func__);
|
||||
|
@ -132,7 +132,7 @@ int spi_write_register(const struct flashctx *flash, enum flash_reg reg, uint8_t
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!flash->mst->spi.probe_opcode(flash, write_cmd[0])) {
|
||||
if (!spi_probe_opcode(flash, write_cmd[0])) {
|
||||
msg_pdbg("%s: write to register %d not supported by programmer, ignoring.\n", __func__, reg);
|
||||
return SPI_INVALID_OPCODE;
|
||||
}
|
||||
@ -246,7 +246,7 @@ int spi_read_register(const struct flashctx *flash, enum flash_reg reg, uint8_t
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!flash->mst->spi.probe_opcode(flash, read_cmd)) {
|
||||
if (!spi_probe_opcode(flash, read_cmd)) {
|
||||
msg_pdbg("%s: read from register %d not supported by programmer.\n", __func__, reg);
|
||||
return SPI_INVALID_OPCODE;
|
||||
}
|
||||
|
@ -469,7 +469,6 @@ static const struct spi_master spi_programmer_stlinkv3 = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = stlinkv3_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
static int stlinkv3_spi_init(const struct programmer_cfg *cfg)
|
||||
|
@ -171,7 +171,6 @@ static const struct spi_master spi_master_usbblaster = {
|
||||
.read = default_spi_read,
|
||||
.write_256 = default_spi_write_256,
|
||||
.shutdown = usbblaster_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
/* Returns 0 upon success, a negative number upon errors. */
|
||||
|
@ -192,7 +192,6 @@ static const struct spi_master spi_master_wbsio = {
|
||||
.write_256 = spi_chip_write_1,
|
||||
.write_aai = spi_chip_write_1,
|
||||
.shutdown = wbsio_spi_shutdown,
|
||||
.probe_opcode = default_spi_probe_opcode,
|
||||
};
|
||||
|
||||
int wbsio_check_for_spi(void)
|
||||
|
Loading…
x
Reference in New Issue
Block a user