ipq806x: add v4.9 support
[openwrt/openwrt.git] / target / linux / ipq806x / patches-4.9 / 0015-spi-qup-refactor-spi_qup_prep_sg-to-be-more-take-spe.patch
1 From a24914d34a4c6df4323c6d98950166600da79bc6 Mon Sep 17 00:00:00 2001
2 From: Matthew McClintock <mmcclint@codeaurora.org>
3 Date: Wed, 4 May 2016 16:33:42 -0500
4 Subject: [PATCH 15/37] spi: qup: refactor spi_qup_prep_sg to be more take
5 specific sgl and nent
6
7 This is in preparation for splitting DMA into multiple transacations,
8 this contains no code changes just refactoring.
9
10 Signed-off-by: Matthew McClintock <mmcclint@codeaurora.org>
11 ---
12 drivers/spi/spi-qup.c | 28 +++++++++++-----------------
13 1 file changed, 11 insertions(+), 17 deletions(-)
14
15 --- a/drivers/spi/spi-qup.c
16 +++ b/drivers/spi/spi-qup.c
17 @@ -379,27 +379,19 @@ static void spi_qup_write(struct spi_qup
18 } while (remainder);
19 }
20
21 -static int spi_qup_prep_sg(struct spi_master *master, struct spi_transfer *xfer,
22 - enum dma_transfer_direction dir,
23 - dma_async_tx_callback callback,
24 - void *data)
25 +static int spi_qup_prep_sg(struct spi_master *master, struct scatterlist *sgl,
26 + unsigned int nents, enum dma_transfer_direction dir,
27 + dma_async_tx_callback callback, void *data)
28 {
29 unsigned long flags = DMA_PREP_INTERRUPT | DMA_PREP_FENCE;
30 struct dma_async_tx_descriptor *desc;
31 - struct scatterlist *sgl;
32 struct dma_chan *chan;
33 dma_cookie_t cookie;
34 - unsigned int nents;
35
36 - if (dir == DMA_MEM_TO_DEV) {
37 + if (dir == DMA_MEM_TO_DEV)
38 chan = master->dma_tx;
39 - nents = xfer->tx_sg.nents;
40 - sgl = xfer->tx_sg.sgl;
41 - } else {
42 + else
43 chan = master->dma_rx;
44 - nents = xfer->rx_sg.nents;
45 - sgl = xfer->rx_sg.sgl;
46 - }
47
48 desc = dmaengine_prep_slave_sg(chan, sgl, nents, dir, flags);
49 if (IS_ERR_OR_NULL(desc))
50 @@ -602,8 +594,9 @@ unsigned long timeout)
51 }
52
53 if (xfer->rx_buf) {
54 - ret = spi_qup_prep_sg(master, xfer, DMA_DEV_TO_MEM, rx_done,
55 - &qup->done);
56 + ret = spi_qup_prep_sg(master, xfer->rx_sg.sgl,
57 + xfer->rx_sg.nents, DMA_DEV_TO_MEM,
58 + rx_done, &qup->done);
59 if (ret)
60 return ret;
61
62 @@ -611,8 +604,9 @@ unsigned long timeout)
63 }
64
65 if (xfer->tx_buf) {
66 - ret = spi_qup_prep_sg(master, xfer, DMA_MEM_TO_DEV, tx_done,
67 - &qup->dma_tx_done);
68 + ret = spi_qup_prep_sg(master, xfer->tx_sg.sgl,
69 + xfer->tx_sg.nents, DMA_MEM_TO_DEV,
70 + tx_done, &qup->dma_tx_done);
71 if (ret)
72 return ret;
73