Felix Singer submitted this change.

View Change


Approvals: build bot (Jenkins): Verified Felix Singer: Looks good to me, approved Peter Marheine: Looks good to me, but someone else must approve Anastasia Klimchuk: Looks good to me, approved
spi: Make 'default_spi_write_aai' the default unless defined

A NULL func pointer is necessary and sufficient for the
condition `NULL func pointer => default_spi_write_aai' as to not
need this explicit specification of 'default'.

Therefore Drop the explicit need to specify the 'default_spi_write_aai'
callback function pointer in the spi_master struct. This is a reasonable default for every other driver in the tree with only a few exceptions.

This simplifies the code and driver development.

Change-Id: I7f14aaea0edcf0c08cea0e9cd27d58152707fb2a
Signed-off-by: Edward O'Callaghan <quasisec@google.com>
Reviewed-on: https://review.coreboot.org/c/flashrom/+/67479
Reviewed-by: Peter Marheine <pmarheine@chromium.org>
Reviewed-by: Anastasia Klimchuk <aklm@chromium.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Felix Singer <felixsinger@posteo.net>
---
M bitbang_spi.c
M buspirate_spi.c
M ch341a_spi.c
M digilent_spi.c
M dummyflasher.c
M ft2232_spi.c
M ichspi.c
M jlink_spi.c
M linux_spi.c
M mediatek_i2c_spi.c
M mstarddc_spi.c
M ni845x_spi.c
M pickit2_spi.c
M raiden_debug_spi.c
M sb600spi.c
M serprog.c
M spi.c
M stlinkv3_spi.c
M usbblaster_spi.c
19 files changed, 28 insertions(+), 24 deletions(-)

diff --git a/bitbang_spi.c b/bitbang_spi.c
index fadca70..7919e45 100644
--- a/bitbang_spi.c
+++ b/bitbang_spi.c
@@ -146,7 +146,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = bitbang_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/buspirate_spi.c b/buspirate_spi.c
index dbaac4e..a40fb70 100644
--- a/buspirate_spi.c
+++ b/buspirate_spi.c
@@ -181,7 +181,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = buspirate_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/ch341a_spi.c b/ch341a_spi.c
index fe18d13..75eaf86 100644
--- a/ch341a_spi.c
+++ b/ch341a_spi.c
@@ -416,7 +416,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = ch341a_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
.delay = ch341a_spi_delay,
diff --git a/digilent_spi.c b/digilent_spi.c
index 6575cbf..55cb6ec 100644
--- a/digilent_spi.c
+++ b/digilent_spi.c
@@ -336,7 +336,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = digilent_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/dummyflasher.c b/dummyflasher.c
index e5a9c12..1960e92 100644
--- a/dummyflasher.c
+++ b/dummyflasher.c
@@ -929,7 +929,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = dummy_spi_write_256,
- .write_aai = default_spi_write_aai,
.probe_opcode = dummy_spi_probe_opcode,
};

diff --git a/ft2232_spi.c b/ft2232_spi.c
index aec21bc..dfec1a0 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -299,7 +299,6 @@
.multicommand = ft2232_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = ft2232_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/ichspi.c b/ichspi.c
index 7b23b42..1522d2b 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1947,7 +1947,6 @@
.unmap_flash_region = physunmap,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
};

static const struct spi_master spi_master_ich9 = {
@@ -1959,7 +1958,6 @@
.unmap_flash_region = physunmap,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.probe_opcode = ich_spi_probe_opcode,
};

@@ -2383,7 +2381,6 @@
.unmap_flash_region = physunmap,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.probe_opcode = ich_spi_probe_opcode,
};

diff --git a/jlink_spi.c b/jlink_spi.c
index 63d15b8..ad2ca78 100644
--- a/jlink_spi.c
+++ b/jlink_spi.c
@@ -187,7 +187,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.features = SPI_MASTER_4BA,
.shutdown = jlink_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
diff --git a/linux_spi.c b/linux_spi.c
index ee02304..d65b3e8 100644
--- a/linux_spi.c
+++ b/linux_spi.c
@@ -119,7 +119,6 @@
.multicommand = default_spi_send_multicommand,
.read = linux_spi_read,
.write_256 = linux_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = linux_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/mediatek_i2c_spi.c b/mediatek_i2c_spi.c
index 3aa9dd9..c15df05 100644
--- a/mediatek_i2c_spi.c
+++ b/mediatek_i2c_spi.c
@@ -459,7 +459,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = mediatek_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/mstarddc_spi.c b/mstarddc_spi.c
index 0c11717..bd65281 100644
--- a/mstarddc_spi.c
+++ b/mstarddc_spi.c
@@ -145,7 +145,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = mstarddc_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/ni845x_spi.c b/ni845x_spi.c
index 2750334..fd5057d 100644
--- a/ni845x_spi.c
+++ b/ni845x_spi.c
@@ -535,7 +535,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = ni845x_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/pickit2_spi.c b/pickit2_spi.c
index e8c80af..86c5403 100644
--- a/pickit2_spi.c
+++ b/pickit2_spi.c
@@ -383,7 +383,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = pickit2_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/raiden_debug_spi.c b/raiden_debug_spi.c
index 8260abd..d1a09d7 100644
--- a/raiden_debug_spi.c
+++ b/raiden_debug_spi.c
@@ -1323,7 +1323,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = raiden_debug_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/sb600spi.c b/sb600spi.c
index 8c018a3..5b9ac45 100644
--- a/sb600spi.c
+++ b/sb600spi.c
@@ -604,7 +604,6 @@
.unmap_flash_region = physunmap,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = sb600spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
@@ -618,7 +617,6 @@
.unmap_flash_region = physunmap,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = sb600spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
@@ -632,7 +630,6 @@
.unmap_flash_region = physunmap,
.read = promontory_read_memmapped,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = sb600spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/serprog.c b/serprog.c
index 84dfd23..4e131e5 100644
--- a/serprog.c
+++ b/serprog.c
@@ -464,7 +464,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.probe_opcode = default_spi_probe_opcode,
.delay = serprog_delay,
};
diff --git a/spi.c b/spi.c
index e708ba9..6c2c4c4 100644
--- a/spi.c
+++ b/spi.c
@@ -131,7 +131,9 @@

int spi_aai_write(struct flashctx *flash, const uint8_t *buf, unsigned int start, unsigned int len)
{
- return flash->mst->spi.write_aai(flash, buf, start, len);
+ if (flash->mst->spi.write_aai)
+ return flash->mst->spi.write_aai(flash, buf, start, len);
+ return default_spi_write_aai(flash, buf, start, len);
}

bool default_spi_probe_opcode(const struct flashctx *flash, uint8_t opcode)
@@ -150,7 +152,7 @@
}
}

- if (!mst->write_aai || !mst->write_256 || !mst->read || !mst->command ||
+ if (!mst->write_256 || !mst->read || !mst->command ||
!mst->multicommand || !mst->probe_opcode ||
((mst->command == default_spi_send_command) &&
(mst->multicommand == default_spi_send_multicommand))) {
diff --git a/stlinkv3_spi.c b/stlinkv3_spi.c
index 1d5763b..16a66b4 100644
--- a/stlinkv3_spi.c
+++ b/stlinkv3_spi.c
@@ -469,7 +469,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = stlinkv3_spi_shutdown,
.probe_opcode = default_spi_probe_opcode,
};
diff --git a/usbblaster_spi.c b/usbblaster_spi.c
index 5e2c020..75d5be7 100644
--- a/usbblaster_spi.c
+++ b/usbblaster_spi.c
@@ -171,7 +171,6 @@
.multicommand = default_spi_send_multicommand,
.read = default_spi_read,
.write_256 = default_spi_write_256,
- .write_aai = default_spi_write_aai,
.shutdown = usbblaster_shutdown,
.probe_opcode = default_spi_probe_opcode,
};

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

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I7f14aaea0edcf0c08cea0e9cd27d58152707fb2a
Gerrit-Change-Number: 67479
Gerrit-PatchSet: 7
Gerrit-Owner: Edward O'Callaghan <quasisec@chromium.org>
Gerrit-Reviewer: Anastasia Klimchuk <aklm@chromium.org>
Gerrit-Reviewer: Felix Singer <felixsinger@posteo.net>
Gerrit-Reviewer: Peter Marheine <pmarheine@chromium.org>
Gerrit-Reviewer: Thomas Heijligen <src@posteo.de>
Gerrit-Reviewer: build bot (Jenkins) <no-reply@coreboot.org>
Gerrit-MessageType: merged