On 0 byte transfer request, return straight from the xfer function after finalizing the transfer. Signed-off-by: Alain Volmat <alain.volmat@xxxxxx> --- drivers/spi/spi-stm32.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/spi/spi-stm32.c b/drivers/spi/spi-stm32.c index 177f82700de0..b909afd9e99b 100644 --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -1658,6 +1658,12 @@ static int stm32_spi_transfer_one(struct spi_master *master, unsigned long timeout; int ret; + /* Don't do anything on 0 bytes transfers */ + if (transfer->len == 0) { + spi->xfer_status = 0; + goto finalize; + } + spi->tx_buf = transfer->tx_buf; spi->rx_buf = transfer->rx_buf; spi->tx_len = spi->tx_buf ? transfer->len : 0; @@ -1702,6 +1708,7 @@ static int stm32_spi_transfer_one(struct spi_master *master, spi->cfg->disable(spi); +finalize: spi_finalize_current_transfer(master); return spi->xfer_status; -- 2.7.4