Skip to content

Commit

Permalink
spi: stm32: properly handle 0 byte transfer
Browse files Browse the repository at this point in the history
[ Upstream commit 2269f5a ]

On 0 byte transfer request, return straight from the
xfer function after finalizing the transfer.

Fixes: dcbe0d8 ("spi: add driver for STM32 SPI controller")
Signed-off-by: Alain Volmat <alain.volmat@foss.st.com>
Link: https://lore.kernel.org/r/1612551572-495-2-git-send-email-alain.volmat@foss.st.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Alain Volmat authored and gregkh committed Mar 4, 2021
1 parent 3cb8510 commit 046a815
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/spi/spi-stm32.c
Expand Up @@ -1668,6 +1668,10 @@ static int stm32_spi_transfer_one(struct spi_master *master,
struct stm32_spi *spi = spi_master_get_devdata(master);
int ret;

/* Don't do anything on 0 bytes transfers */
if (transfer->len == 0)
return 0;

spi->tx_buf = transfer->tx_buf;
spi->rx_buf = transfer->rx_buf;
spi->tx_len = spi->tx_buf ? transfer->len : 0;
Expand Down

0 comments on commit 046a815

Please sign in to comment.