xtensa/esp32: Fix wrong math round operation on DMA init

This commit is contained in:
Gustavo Henrique Nihei 2021-03-26 12:20:30 -03:00 committed by Xiang Xiao
parent eb505ed866
commit d3342795a8

View File

@ -43,6 +43,10 @@
# define MIN(a,b) (a < b ? a : b)
#endif
#ifndef ALIGN_UP
# define ALIGN_UP(num, align) (((num) + ((align) - 1)) & ~((align) - 1))
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
@ -82,11 +86,9 @@ uint32_t esp32_dma_init(struct esp32_dmadesc_s *dmadesc, uint32_t num,
{
data_len = MIN(bytes, ESP32_DMA_DATALEN_MAX);
/* Round the number of bytes to the nearest word, since the buffer
* length must be word-aligned.
*/
/* Buffer length must be rounded to next 32-bit boundary. */
buf_len = (data_len + sizeof(uintptr_t) - 1) / sizeof(uintptr_t);
buf_len = ALIGN_UP(data_len, sizeof(uintptr_t));
dmadesc[i].ctrl = (data_len << DMA_CTRL_DATALEN_S) |
(buf_len << DMA_CTRL_BUFLEN_S) |