]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
tty: serial: fsl_lpuart: adjust buffer length to the intended size
authorShenwei Wang <shenwei.wang@nxp.com>
Mon, 10 Apr 2023 19:55:55 +0000 (14:55 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 May 2023 09:11:44 +0000 (11:11 +0200)
[ Upstream commit f73fd750552524b06b5d77ebfdd106ccc8fcac61 ]

Based on the fls function definition provided below, we should not
subtract 1 to obtain the correct buffer length:

fls(0) = 0, fls(1) = 1, fls(0x80000000) = 32.

Fixes: 5887ad43ee02 ("tty: serial: fsl_lpuart: Use cyclic DMA for Rx")
Signed-off-by: Shenwei Wang <shenwei.wang@nxp.com>
Link: https://lore.kernel.org/r/20230410195555.1003900-1-shenwei.wang@nxp.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/tty/serial/fsl_lpuart.c

index 20dd476e4d1a1c5b2f2ec79f79c5b5333c53b92d..e7ab8ec032cfeafb8facb62d9a32bfd0e855be90 100644 (file)
@@ -998,7 +998,7 @@ static inline int lpuart_start_rx_dma(struct lpuart_port *sport)
         * 10ms at any baud rate.
         */
        sport->rx_dma_rng_buf_len = (DMA_RX_TIMEOUT * baud /  bits / 1000) * 2;
-       sport->rx_dma_rng_buf_len = (1 << (fls(sport->rx_dma_rng_buf_len) - 1));
+       sport->rx_dma_rng_buf_len = (1 << fls(sport->rx_dma_rng_buf_len));
        if (sport->rx_dma_rng_buf_len < 16)
                sport->rx_dma_rng_buf_len = 16;