Skip to content

Commit 1d5dfa7

Browse files
Alain VolmatPatrice Chotard
authored andcommitted
spi: stm32_spi: allow having xferlen equal to 0
The SPI API allows to have a 0 sized transfer length, in which case, from an SPI interface point of view, only the CS signal get updated if necessary. Add a check in order to allow having xferlen equal to 0. Change-Id: Ib0034eea1d5480022ec2e4cfc0f7131f15486805 Signed-off-by: Alain Volmat <alain.volmat@foss.st.com> Reviewed-on: https://gerrit.st.com/c/mpu/oe/st/u-boot/+/523211 Domain-Review: Amelie DELAUNAY <amelie.delaunay@foss.st.com> Reviewed-by: Alain VOLMAT <alain.volmat@st.com> ACI: CIBUILD <MDG-smet-aci-builds@list.st.com> ACI: CITOOLS <MDG-smet-aci-reviews@list.st.com> Tested-by: Alain VOLMAT <alain.volmat@st.com> Reviewed-by: Patrice CHOTARD <patrice.chotard@foss.st.com>
1 parent dba4df0 commit 1d5dfa7

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

drivers/spi/stm32_spi.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,10 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen,
445445
if (flags & SPI_XFER_BEGIN)
446446
stm32_spi_set_cs(bus, slave_plat->cs, false);
447447

448+
/* If transfer length is 0, jump right to the end */
449+
if (xferlen == 0)
450+
goto done;
451+
448452
/* Be sure to have data in fifo before starting data transfer */
449453
if (priv->tx_buf)
450454
stm32_spi_write_txfifo(bus);
@@ -493,6 +497,7 @@ static int stm32_spi_xfer(struct udevice *slave, unsigned int bitlen,
493497
setbits_le32(base + STM32_SPI_IFCR, SPI_IFCR_ALL);
494498
stm32_spi_stopxfer(bus);
495499

500+
done:
496501
if (flags & SPI_XFER_END)
497502
stm32_spi_set_cs(bus, slave_plat->cs, true);
498503

0 commit comments

Comments
 (0)