Edward O'Callaghan has uploaded this change for review.

View Change

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.

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>
---
M bitbang_spi.c
M buspirate_spi.c
M ch341a_spi.c
M dediprog.c
M digilent_spi.c
M dirtyjtag_spi.c
M ft2232_spi.c
M include/programmer.h
M it87spi.c
M jlink_spi.c
M linux_spi.c
M mediatek_i2c_spi.c
M mstarddc_spi.c
M ni845x_spi.c
M parade_lspcon.c
M pickit2_spi.c
M raiden_debug_spi.c
M realtek_mst_i2c_spi.c
M sb600spi.c
M serprog.c
M spi.c
M stlinkv3_spi.c
M usbblaster_spi.c
M wbsio_spi.c
24 files changed, 21 insertions(+), 32 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/64/70264/1
diff --git a/bitbang_spi.c b/bitbang_spi.c
index f7ded1f..67f6001 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -148,7 +148,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = bitbang_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

int register_spi_bitbang_master(const struct bitbang_spi_master *master, void *spi_data)
diff --git a/buspirate_spi.c b/buspirate_spi.c
index dbaac4e..410f6f7 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -183,7 +183,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = buspirate_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static const struct buspirate_speeds spispeeds[] = {
diff --git a/ch341a_spi.c b/ch341a_spi.c
index 294a6a6..7400b40 100644
--- a/ch341a_spi.c
+++ b/ch341a_spi.c
@@ -418,7 +418,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = ch341a_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static int ch341a_spi_init(const struct programmer_cfg *cfg)
diff --git a/dediprog.c b/dediprog.c
index b4279d8..478a33d 100644
--- a/dediprog.c
+++ b/dediprog.c
@@ -1039,7 +1039,6 @@
.write_256 = dediprog_spi_write_256,
.write_aai = dediprog_spi_write_aai,
.shutdown = dediprog_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

/*
diff --git a/digilent_spi.c b/digilent_spi.c
index 6575cbf..70bf58d 100644
--- a/digilent_spi.c
+++ b/digilent_spi.c
@@ -338,7 +338,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = digilent_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static bool default_reset(struct libusb_device_handle *handle)
diff --git a/dirtyjtag_spi.c b/dirtyjtag_spi.c
index 42169ed..42445ad 100644
--- a/dirtyjtag_spi.c
+++ b/dirtyjtag_spi.c
@@ -198,7 +198,6 @@
.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)
diff --git a/ft2232_spi.c b/ft2232_spi.c
index aec21bc..ff88d20 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -301,7 +301,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = ft2232_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

/* Returns 0 upon success, a negative number upon errors. */
diff --git a/include/programmer.h b/include/programmer.h
index 55e300a..bbe397d 100644
--- a/include/programmer.h
+++ b/include/programmer.h
@@ -312,7 +312,7 @@
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)(struct flashctx *flash, uint8_t opcode);
+ bool (*probe_opcode)(struct flashctx *flash, uint8_t opcode); /* NULL func implies true. */
void *data;
};

@@ -322,7 +322,6 @@
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(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. */
diff --git a/it87spi.c b/it87spi.c
index a022041..7893900 100644
--- a/it87spi.c
+++ b/it87spi.c
@@ -321,7 +321,6 @@
.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)
diff --git a/jlink_spi.c b/jlink_spi.c
index 63d15b8..49c6216 100644
--- a/jlink_spi.c
+++ b/jlink_spi.c
@@ -190,7 +190,6 @@
.write_aai = default_spi_write_aai,
.features = SPI_MASTER_4BA,
.shutdown = jlink_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static int jlink_spi_init(const struct programmer_cfg *cfg)
diff --git a/linux_spi.c b/linux_spi.c
index ee02304..e599e94 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -121,7 +121,6 @@
.write_256 = linux_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = linux_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

/* Read max buffer size from sysfs, or use page size as fallback. */
diff --git a/mediatek_i2c_spi.c b/mediatek_i2c_spi.c
index 3aa9dd9..2fc1cd9 100644
--- a/mediatek_i2c_spi.c
+++ b/mediatek_i2c_spi.c
@@ -461,7 +461,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = mediatek_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static int get_params(const struct programmer_cfg *cfg, bool *allow_brick)
diff --git a/mstarddc_spi.c b/mstarddc_spi.c
index 0c11717..09d54a0 100644
--- a/mstarddc_spi.c
+++ b/mstarddc_spi.c
@@ -147,7 +147,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = mstarddc_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

/* Returns 0 upon success, a negative number upon errors. */
diff --git a/ni845x_spi.c b/ni845x_spi.c
index 2750334..f418ab9 100644
--- a/ni845x_spi.c
+++ b/ni845x_spi.c
@@ -537,7 +537,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = ni845x_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static int ni845x_spi_init(const struct programmer_cfg *cfg)
diff --git a/parade_lspcon.c b/parade_lspcon.c
index a50346e..88ac5bd 100644
--- a/parade_lspcon.c
+++ b/parade_lspcon.c
@@ -437,7 +437,6 @@
.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)
diff --git a/pickit2_spi.c b/pickit2_spi.c
index e8c80af..a2518d2 100644
--- a/pickit2_spi.c
+++ b/pickit2_spi.c
@@ -385,7 +385,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = pickit2_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static int pickit2_spi_init(const struct programmer_cfg *cfg)
diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c
index 517b173..bb72081 100644
--- a/raiden_debug_spi.c
+++ b/raiden_debug_spi.c
@@ -1325,7 +1325,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = raiden_debug_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static int match_endpoint(struct libusb_endpoint_descriptor const *descriptor,
diff --git a/realtek_mst_i2c_spi.c b/realtek_mst_i2c_spi.c
index 2a5d5ed..1e9d8a3 100644
--- a/realtek_mst_i2c_spi.c
+++ b/realtek_mst_i2c_spi.c
@@ -441,7 +441,6 @@
.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)
diff --git a/sb600spi.c b/sb600spi.c
index 8c018a3..40b7778 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -606,7 +606,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = sb600spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static const struct spi_master spi_master_yangtze = {
@@ -620,7 +619,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = sb600spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static const struct spi_master spi_master_promontory = {
@@ -634,7 +632,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = sb600spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

int sb600_probe_spi(const struct programmer_cfg *cfg, struct pci_dev *dev)
diff --git a/serprog.c b/serprog.c
index a3a3db3..fbf4cf6 100644
--- a/serprog.c
+++ b/serprog.c
@@ -463,7 +463,6 @@
.read = default_spi_read,
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
- .probe_opcode = default_spi_probe_opcode,
};

static int sp_check_opbuf_usage(int bytes_to_be_added)
diff --git a/spi.c b/spi.c
index 38d8d01..9f820d7 100644
--- a/spi.c
+++ b/spi.c
@@ -134,11 +134,6 @@
return flash->mst->spi.write_aai(flash, buf, start, len);
}

-bool default_spi_probe_opcode(struct flashctx *flash, uint8_t opcode)
-{
- return true;
-}
-
int register_spi_master(const struct spi_master *mst, void *data)
{
struct registered_master rmst = {0};
@@ -151,7 +146,7 @@
}

if (!mst->write_aai || !mst->write_256 || !mst->read || !mst->command ||
- !mst->multicommand || !mst->probe_opcode ||
+ !mst->multicommand ||
((mst->command == default_spi_send_command) &&
(mst->multicommand == default_spi_send_multicommand))) {
msg_perr("%s called with incomplete master definition. "
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c
index 1d5763b..3b2837b 100644
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -471,7 +471,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = stlinkv3_spi_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

static int stlinkv3_spi_init(const struct programmer_cfg *cfg)
diff --git a/usbblaster_spi.c b/usbblaster_spi.c
index 5e2c020..8c52ec6 100644
--- a/usbblaster_spi.c
+++ b/usbblaster_spi.c
@@ -173,7 +173,6 @@
.write_256 = default_spi_write_256,
.write_aai = default_spi_write_aai,
.shutdown = usbblaster_shutdown,
- .probe_opcode = default_spi_probe_opcode,
};

/* Returns 0 upon success, a negative number upon errors. */
diff --git a/wbsio_spi.c b/wbsio_spi.c
index 1aa8729..04bb08f 100644
--- a/wbsio_spi.c
+++ b/wbsio_spi.c
@@ -193,7 +193,6 @@
.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)

To view, visit change 70264. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: Id502c5d2596ad1db52faf05723083620e4c52c12
Gerrit-Change-Number: 70264
Gerrit-PatchSet: 1
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-MessageType: newchange