diff --git a/drivers/dma/stm32-dma.c b/drivers/dma/stm32-dma.c index 1b2063fb3d1d6..bf3042b655485 100644 --- a/drivers/dma/stm32-dma.c +++ b/drivers/dma/stm32-dma.c @@ -278,7 +278,7 @@ static enum dma_slave_buswidth stm32_dma_get_max_width(u32 buf_len, max_width > DMA_SLAVE_BUSWIDTH_1_BYTE) max_width = max_width >> 1; - if (buf_addr % max_width) + if (buf_addr & (max_width - 1)) max_width = DMA_SLAVE_BUSWIDTH_1_BYTE; return max_width; @@ -754,7 +754,7 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan, * Set memory burst size - burst not possible if address is not aligned on * the address boundary equal to the size of the transfer */ - if (buf_addr % buf_len) + if (buf_addr & (buf_len - 1)) src_maxburst = 1; else src_maxburst = STM32_DMA_MAX_BURST; @@ -810,7 +810,7 @@ static int stm32_dma_set_xfer_param(struct stm32_dma_chan *chan, * Set memory burst size - burst not possible if address is not aligned on * the address boundary equal to the size of the transfer */ - if (buf_addr % buf_len) + if (buf_addr & (buf_len - 1)) dst_maxburst = 1; else dst_maxburst = STM32_DMA_MAX_BURST;