Skip to content

Commit ba172c7

Browse files
geertugregkh
authored andcommitted
serial: sh-sci: Use incrementing pointers instead of stack array
There's no need to keep all buffer and DMA pointers on the stack. Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 47b0e94 commit ba172c7

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

drivers/tty/serial/sh-sci.c

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1734,18 +1734,16 @@ static void sci_request_dma(struct uart_port *port)
17341734
chan = dma_request_channel(mask, filter, param);
17351735
dev_dbg(port->dev, "%s: RX: got channel %p\n", __func__, chan);
17361736
if (chan) {
1737-
dma_addr_t dma[2];
1738-
void *buf[2];
1739-
int i;
1737+
unsigned int i;
1738+
dma_addr_t dma;
1739+
void *buf;
17401740

17411741
s->chan_rx = chan;
17421742

17431743
s->buf_len_rx = 2 * max_t(size_t, 16, port->fifosize);
1744-
buf[0] = dma_alloc_coherent(chan->device->dev,
1745-
s->buf_len_rx * 2, &dma[0],
1746-
GFP_KERNEL);
1747-
1748-
if (!buf[0]) {
1744+
buf = dma_alloc_coherent(chan->device->dev, s->buf_len_rx * 2,
1745+
&dma, GFP_KERNEL);
1746+
if (!buf) {
17491747
dev_warn(port->dev,
17501748
"Failed to allocate Rx dma buffer, using PIO\n");
17511749
dma_release_channel(chan);
@@ -1754,16 +1752,16 @@ static void sci_request_dma(struct uart_port *port)
17541752
return;
17551753
}
17561754

1757-
buf[1] = buf[0] + s->buf_len_rx;
1758-
dma[1] = dma[0] + s->buf_len_rx;
1759-
17601755
for (i = 0; i < 2; i++) {
17611756
struct scatterlist *sg = &s->sg_rx[i];
17621757

17631758
sg_init_table(sg, 1);
1764-
sg_set_page(sg, virt_to_page(buf[i]), s->buf_len_rx,
1765-
(uintptr_t)buf[i] & ~PAGE_MASK);
1766-
sg_dma_address(sg) = dma[i];
1759+
sg_set_page(sg, virt_to_page(buf), s->buf_len_rx,
1760+
(uintptr_t)buf & ~PAGE_MASK);
1761+
sg_dma_address(sg) = dma;
1762+
1763+
buf += s->buf_len_rx;
1764+
dma += s->buf_len_rx;
17671765
}
17681766

17691767
INIT_WORK(&s->work_rx, work_fn_rx);

0 commit comments

Comments
 (0)