Skip to content

Commit

Permalink
tty: atmel_serial: define macro for RX size
Browse files Browse the repository at this point in the history
It is repeated in the code and there is also a big warning by
ATMEL_SERIAL_RINGSIZE. So define ATMEL_SERIAL_RX_SIZE and use it
appropriatelly.

The macro uses array_size() and kmalloc_array() is switched to
kmalloc().

Signed-off-by: Jiri Slaby (SUSE) <jirislaby@kernel.org>
Cc: Richard Genoud <richard.genoud@gmail.com>
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Alexandre Belloni <alexandre.belloni@bootlin.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20240405060826.2521-15-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Jiri Slaby (SUSE) authored and Greg Kroah-Hartman committed Apr 9, 2024
1 parent b9cea51 commit 12beddd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions drivers/tty/serial/atmel_serial.c
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ struct atmel_uart_char {
* can contain up to 1024 characters in PIO mode and up to 4096 characters in
* DMA mode.
*/
#define ATMEL_SERIAL_RINGSIZE 1024
#define ATMEL_SERIAL_RINGSIZE 1024
#define ATMEL_SERIAL_RX_SIZE array_size(sizeof(struct atmel_uart_char), \
ATMEL_SERIAL_RINGSIZE)

/*
* at91: 6 USARTs and one DBGU port (SAM9260)
Expand Down Expand Up @@ -1208,7 +1210,7 @@ static int atmel_prepare_rx_dma(struct uart_port *port)
BUG_ON(!PAGE_ALIGNED(ring->buf));
sg_set_page(&atmel_port->sg_rx,
virt_to_page(ring->buf),
sizeof(struct atmel_uart_char) * ATMEL_SERIAL_RINGSIZE,
ATMEL_SERIAL_RX_SIZE,
offset_in_page(ring->buf));
nent = dma_map_sg(port->dev,
&atmel_port->sg_rx,
Expand Down Expand Up @@ -2947,9 +2949,7 @@ static int atmel_serial_probe(struct platform_device *pdev)

if (!atmel_use_pdc_rx(&atmel_port->uart)) {
ret = -ENOMEM;
data = kmalloc_array(ATMEL_SERIAL_RINGSIZE,
sizeof(struct atmel_uart_char),
GFP_KERNEL);
data = kmalloc(ATMEL_SERIAL_RX_SIZE, GFP_KERNEL);
if (!data)
goto err_clk_disable_unprepare;
atmel_port->rx_ring.buf = data;
Expand Down

0 comments on commit 12beddd

Please sign in to comment.