summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/drivers/spi/spi-generic.c4
-rw-r--r--src/include/spi-generic.h3
2 files changed, 6 insertions, 1 deletions
diff --git a/src/drivers/spi/spi-generic.c b/src/drivers/spi/spi-generic.c
index 9796663da2..e6ec7bd8d5 100644
--- a/src/drivers/spi/spi-generic.c
+++ b/src/drivers/spi/spi-generic.c
@@ -98,6 +98,10 @@ unsigned int spi_crop_chunk(const struct spi_slave *slave, unsigned int cmd_len,
if (deduct_opcode_len)
cmd_len--;
+ /* Subtract command length from useable buffer size. If
+ deduct_opcode_len is set, only subtract the number command bytes
+ after the opcode. If the adjusted cmd_len is larger than ctrlr_max
+ return 0 to inidicate an error. */
if (deduct_cmd_len) {
if (ctrlr_max >= cmd_len) {
ctrlr_max -= cmd_len;
diff --git a/src/include/spi-generic.h b/src/include/spi-generic.h
index 77a3c09a79..acb22ec1d2 100644
--- a/src/include/spi-generic.h
+++ b/src/include/spi-generic.h
@@ -111,7 +111,8 @@ enum ctrlr_prot_type {
enum {
/* Deduct the command length from the spi_crop_chunk() calculation for
- sizing a transaction. */
+ sizing a transaction. If SPI_CNTRLR_DEDUCT_OPCODE_LEN is set, only
+ the bytes after the command byte will be deducted. */
SPI_CNTRLR_DEDUCT_CMD_LEN = 1 << 0,
/* Remove the opcode size from the command length used in the
spi_crop_chunk() calculation. Controllers which have a dedicated