From 1d8681965c42d90368c22b9ac40bd3268821ccfb Mon Sep 17 00:00:00 2001 From: Rami Saad Date: Fri, 25 Nov 2022 16:29:25 -0500 Subject: [PATCH] drivers: spi: fix 16 bit spi dma transfers for the STM32 driver Calculate the correct dma segment length for STM32 16 bit spi dma transfers Fixes zephyrproject-rtos#52563 Signed-off-by: Rami Saad --- drivers/spi/spi_ll_stm32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/spi/spi_ll_stm32.c b/drivers/spi/spi_ll_stm32.c index c4f2b36c799e67..83770113affe12 100644 --- a/drivers/spi/spi_ll_stm32.c +++ b/drivers/spi/spi_ll_stm32.c @@ -206,14 +206,14 @@ static int spi_dma_move_buffers(const struct device *dev, size_t len) int ret; size_t dma_segment_len; - dma_segment_len = len / data->dma_rx.dma_cfg.dest_data_size; + dma_segment_len = len * data->dma_rx.dma_cfg.dest_data_size; ret = spi_stm32_dma_rx_load(dev, data->ctx.rx_buf, dma_segment_len); if (ret != 0) { return ret; } - dma_segment_len = len / data->dma_tx.dma_cfg.source_data_size; + dma_segment_len = len * data->dma_tx.dma_cfg.source_data_size; ret = spi_stm32_dma_tx_load(dev, data->ctx.tx_buf, dma_segment_len); return ret;