1 From 6d5f37f166bb07b04b4d42e9d1f5427b7931cd3c Mon Sep 17 00:00:00 2001
2 From: Abhishek Sahu <absahu@codeaurora.org>
3 Date: Mon, 12 Mar 2018 18:44:53 +0530
4 Subject: [PATCH 04/13] i2c: qup: remove redundant variables for BAM SG count
6 The rx_nents and tx_nents are redundant. rx_buf and tx_buf can
7 be used for total number of SG entries. Since rx_buf and tx_buf
8 give the impression that it is buffer instead of count so rename
9 it to tx_cnt and rx_cnt for giving it more meaningful variable
12 Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
13 Reviewed-by: Austin Christ <austinwc@codeaurora.org>
14 Reviewed-by: Andy Gross <andy.gross@linaro.org>
15 Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
17 drivers/i2c/busses/i2c-qup.c | 42 ++++++++++++++++--------------------
18 1 file changed, 18 insertions(+), 24 deletions(-)
20 --- a/drivers/i2c/busses/i2c-qup.c
21 +++ b/drivers/i2c/busses/i2c-qup.c
22 @@ -683,8 +683,8 @@ static int qup_i2c_bam_do_xfer(struct qu
23 struct dma_async_tx_descriptor *txd, *rxd = NULL;
24 int ret = 0, idx = 0, limit = QUP_READ_LIMIT;
25 dma_cookie_t cookie_rx, cookie_tx;
26 - u32 rx_nents = 0, tx_nents = 0, len, blocks, rem;
27 - u32 i, tlen, tx_len, tx_buf = 0, rx_buf = 0, off = 0;
28 + u32 len, blocks, rem;
29 + u32 i, tlen, tx_len, tx_cnt = 0, rx_cnt = 0, off = 0;
33 @@ -698,9 +698,6 @@ static int qup_i2c_bam_do_xfer(struct qu
34 rem = msg->len - (blocks - 1) * limit;
36 if (msg->flags & I2C_M_RD) {
37 - rx_nents += (blocks * 2) + 1;
40 while (qup->blk.pos < blocks) {
41 tlen = (i == (blocks - 1)) ? rem : limit;
42 tags = &qup->start_tag.start[off + len];
43 @@ -708,14 +705,14 @@ static int qup_i2c_bam_do_xfer(struct qu
44 qup->blk.data_len -= tlen;
46 /* scratch buf to read the start and len tags */
47 - ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++],
48 + ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++],
49 &qup->brx.tag.start[0],
50 2, qup, DMA_FROM_DEVICE);
55 - ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++],
56 + ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++],
60 @@ -725,7 +722,7 @@ static int qup_i2c_bam_do_xfer(struct qu
64 - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++],
65 + ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++],
66 &qup->start_tag.start[off],
67 len, qup, DMA_TO_DEVICE);
69 @@ -733,28 +730,26 @@ static int qup_i2c_bam_do_xfer(struct qu
72 /* scratch buf to read the BAM EOT and FLUSH tags */
73 - ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++],
74 + ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++],
75 &qup->brx.tag.start[0],
76 2, qup, DMA_FROM_DEVICE);
80 - tx_nents += (blocks * 2);
82 while (qup->blk.pos < blocks) {
83 tlen = (i == (blocks - 1)) ? rem : limit;
84 tags = &qup->start_tag.start[off + tx_len];
85 len = qup_i2c_set_tags(tags, qup, msg, 1);
86 qup->blk.data_len -= tlen;
88 - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++],
89 + ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++],
96 - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++],
97 + ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++],
99 tlen, qup, DMA_TO_DEVICE);
101 @@ -766,26 +761,25 @@ static int qup_i2c_bam_do_xfer(struct qu
103 if (idx == (num - 1)) {
107 qup->btx.tag.start[0] =
111 qup->btx.tag.start[len - 1] =
113 - ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++],
114 + ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++],
115 &qup->btx.tag.start[0],
116 len, qup, DMA_TO_DEVICE);
126 - txd = dmaengine_prep_slave_sg(qup->btx.dma, qup->btx.sg, tx_nents,
127 + txd = dmaengine_prep_slave_sg(qup->btx.dma, qup->btx.sg, tx_cnt,
129 DMA_PREP_INTERRUPT | DMA_PREP_FENCE);
131 @@ -794,7 +788,7 @@ static int qup_i2c_bam_do_xfer(struct qu
137 txd->callback = qup_i2c_bam_cb;
138 txd->callback_param = qup;
140 @@ -807,9 +801,9 @@ static int qup_i2c_bam_do_xfer(struct qu
142 dma_async_issue_pending(qup->btx.dma);
146 rxd = dmaengine_prep_slave_sg(qup->brx.dma, qup->brx.sg,
147 - rx_nents, DMA_DEV_TO_MEM,
148 + rx_cnt, DMA_DEV_TO_MEM,
151 dev_err(qup->dev, "failed to get rx desc\n");
152 @@ -844,7 +838,7 @@ static int qup_i2c_bam_do_xfer(struct qu
158 writel(QUP_BAM_INPUT_EOT,
159 qup->base + QUP_OUT_FIFO_BASE);
161 @@ -862,10 +856,10 @@ static int qup_i2c_bam_do_xfer(struct qu
165 - dma_unmap_sg(qup->dev, qup->btx.sg, tx_nents, DMA_TO_DEVICE);
166 + dma_unmap_sg(qup->dev, qup->btx.sg, tx_cnt, DMA_TO_DEVICE);
169 - dma_unmap_sg(qup->dev, qup->brx.sg, rx_nents,
171 + dma_unmap_sg(qup->dev, qup->brx.sg, rx_cnt,