mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-07 15:15:29 +00:00
i2c: qup: remove redundant variables for BAM SG count
The rx_nents and tx_nents are redundant. rx_buf and tx_buf can be used for total number of SG entries. Since rx_buf and tx_buf give the impression that it is buffer instead of count so rename it to tx_cnt and rx_cnt for giving it more meaningful variable name. Signed-off-by: Abhishek Sahu <absahu@codeaurora.org> Reviewed-by: Austin Christ <austinwc@codeaurora.org> Reviewed-by: Andy Gross <andy.gross@linaro.org> Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
This commit is contained in:
parent
eb422b539c
commit
6d5f37f166
1 changed files with 18 additions and 24 deletions
|
@ -683,8 +683,8 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
struct dma_async_tx_descriptor *txd, *rxd = NULL;
|
struct dma_async_tx_descriptor *txd, *rxd = NULL;
|
||||||
int ret = 0, idx = 0, limit = QUP_READ_LIMIT;
|
int ret = 0, idx = 0, limit = QUP_READ_LIMIT;
|
||||||
dma_cookie_t cookie_rx, cookie_tx;
|
dma_cookie_t cookie_rx, cookie_tx;
|
||||||
u32 rx_nents = 0, tx_nents = 0, len, blocks, rem;
|
u32 len, blocks, rem;
|
||||||
u32 i, tlen, tx_len, tx_buf = 0, rx_buf = 0, off = 0;
|
u32 i, tlen, tx_len, tx_cnt = 0, rx_cnt = 0, off = 0;
|
||||||
u8 *tags;
|
u8 *tags;
|
||||||
|
|
||||||
while (idx < num) {
|
while (idx < num) {
|
||||||
|
@ -698,9 +698,6 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
rem = msg->len - (blocks - 1) * limit;
|
rem = msg->len - (blocks - 1) * limit;
|
||||||
|
|
||||||
if (msg->flags & I2C_M_RD) {
|
if (msg->flags & I2C_M_RD) {
|
||||||
rx_nents += (blocks * 2) + 1;
|
|
||||||
tx_nents += 1;
|
|
||||||
|
|
||||||
while (qup->blk.pos < blocks) {
|
while (qup->blk.pos < blocks) {
|
||||||
tlen = (i == (blocks - 1)) ? rem : limit;
|
tlen = (i == (blocks - 1)) ? rem : limit;
|
||||||
tags = &qup->start_tag.start[off + len];
|
tags = &qup->start_tag.start[off + len];
|
||||||
|
@ -708,14 +705,14 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
qup->blk.data_len -= tlen;
|
qup->blk.data_len -= tlen;
|
||||||
|
|
||||||
/* scratch buf to read the start and len tags */
|
/* scratch buf to read the start and len tags */
|
||||||
ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++],
|
ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++],
|
||||||
&qup->brx.tag.start[0],
|
&qup->brx.tag.start[0],
|
||||||
2, qup, DMA_FROM_DEVICE);
|
2, qup, DMA_FROM_DEVICE);
|
||||||
|
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++],
|
ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++],
|
||||||
&msg->buf[limit * i],
|
&msg->buf[limit * i],
|
||||||
tlen, qup,
|
tlen, qup,
|
||||||
DMA_FROM_DEVICE);
|
DMA_FROM_DEVICE);
|
||||||
|
@ -725,7 +722,7 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
i++;
|
i++;
|
||||||
qup->blk.pos = i;
|
qup->blk.pos = i;
|
||||||
}
|
}
|
||||||
ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++],
|
ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++],
|
||||||
&qup->start_tag.start[off],
|
&qup->start_tag.start[off],
|
||||||
len, qup, DMA_TO_DEVICE);
|
len, qup, DMA_TO_DEVICE);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -733,28 +730,26 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
|
|
||||||
off += len;
|
off += len;
|
||||||
/* scratch buf to read the BAM EOT and FLUSH tags */
|
/* scratch buf to read the BAM EOT and FLUSH tags */
|
||||||
ret = qup_sg_set_buf(&qup->brx.sg[rx_buf++],
|
ret = qup_sg_set_buf(&qup->brx.sg[rx_cnt++],
|
||||||
&qup->brx.tag.start[0],
|
&qup->brx.tag.start[0],
|
||||||
2, qup, DMA_FROM_DEVICE);
|
2, qup, DMA_FROM_DEVICE);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
} else {
|
} else {
|
||||||
tx_nents += (blocks * 2);
|
|
||||||
|
|
||||||
while (qup->blk.pos < blocks) {
|
while (qup->blk.pos < blocks) {
|
||||||
tlen = (i == (blocks - 1)) ? rem : limit;
|
tlen = (i == (blocks - 1)) ? rem : limit;
|
||||||
tags = &qup->start_tag.start[off + tx_len];
|
tags = &qup->start_tag.start[off + tx_len];
|
||||||
len = qup_i2c_set_tags(tags, qup, msg, 1);
|
len = qup_i2c_set_tags(tags, qup, msg, 1);
|
||||||
qup->blk.data_len -= tlen;
|
qup->blk.data_len -= tlen;
|
||||||
|
|
||||||
ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++],
|
ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++],
|
||||||
tags, len,
|
tags, len,
|
||||||
qup, DMA_TO_DEVICE);
|
qup, DMA_TO_DEVICE);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
tx_len += len;
|
tx_len += len;
|
||||||
ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++],
|
ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++],
|
||||||
&msg->buf[limit * i],
|
&msg->buf[limit * i],
|
||||||
tlen, qup, DMA_TO_DEVICE);
|
tlen, qup, DMA_TO_DEVICE);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
@ -766,26 +761,25 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
|
|
||||||
if (idx == (num - 1)) {
|
if (idx == (num - 1)) {
|
||||||
len = 1;
|
len = 1;
|
||||||
if (rx_nents) {
|
if (rx_cnt) {
|
||||||
qup->btx.tag.start[0] =
|
qup->btx.tag.start[0] =
|
||||||
QUP_BAM_INPUT_EOT;
|
QUP_BAM_INPUT_EOT;
|
||||||
len++;
|
len++;
|
||||||
}
|
}
|
||||||
qup->btx.tag.start[len - 1] =
|
qup->btx.tag.start[len - 1] =
|
||||||
QUP_BAM_FLUSH_STOP;
|
QUP_BAM_FLUSH_STOP;
|
||||||
ret = qup_sg_set_buf(&qup->btx.sg[tx_buf++],
|
ret = qup_sg_set_buf(&qup->btx.sg[tx_cnt++],
|
||||||
&qup->btx.tag.start[0],
|
&qup->btx.tag.start[0],
|
||||||
len, qup, DMA_TO_DEVICE);
|
len, qup, DMA_TO_DEVICE);
|
||||||
if (ret)
|
if (ret)
|
||||||
return ret;
|
return ret;
|
||||||
tx_nents += 1;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
idx++;
|
idx++;
|
||||||
msg++;
|
msg++;
|
||||||
}
|
}
|
||||||
|
|
||||||
txd = dmaengine_prep_slave_sg(qup->btx.dma, qup->btx.sg, tx_nents,
|
txd = dmaengine_prep_slave_sg(qup->btx.dma, qup->btx.sg, tx_cnt,
|
||||||
DMA_MEM_TO_DEV,
|
DMA_MEM_TO_DEV,
|
||||||
DMA_PREP_INTERRUPT | DMA_PREP_FENCE);
|
DMA_PREP_INTERRUPT | DMA_PREP_FENCE);
|
||||||
if (!txd) {
|
if (!txd) {
|
||||||
|
@ -794,7 +788,7 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
goto desc_err;
|
goto desc_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!rx_nents) {
|
if (!rx_cnt) {
|
||||||
txd->callback = qup_i2c_bam_cb;
|
txd->callback = qup_i2c_bam_cb;
|
||||||
txd->callback_param = qup;
|
txd->callback_param = qup;
|
||||||
}
|
}
|
||||||
|
@ -807,9 +801,9 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
|
|
||||||
dma_async_issue_pending(qup->btx.dma);
|
dma_async_issue_pending(qup->btx.dma);
|
||||||
|
|
||||||
if (rx_nents) {
|
if (rx_cnt) {
|
||||||
rxd = dmaengine_prep_slave_sg(qup->brx.dma, qup->brx.sg,
|
rxd = dmaengine_prep_slave_sg(qup->brx.dma, qup->brx.sg,
|
||||||
rx_nents, DMA_DEV_TO_MEM,
|
rx_cnt, DMA_DEV_TO_MEM,
|
||||||
DMA_PREP_INTERRUPT);
|
DMA_PREP_INTERRUPT);
|
||||||
if (!rxd) {
|
if (!rxd) {
|
||||||
dev_err(qup->dev, "failed to get rx desc\n");
|
dev_err(qup->dev, "failed to get rx desc\n");
|
||||||
|
@ -844,7 +838,7 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
goto desc_err;
|
goto desc_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rx_nents)
|
if (rx_cnt)
|
||||||
writel(QUP_BAM_INPUT_EOT,
|
writel(QUP_BAM_INPUT_EOT,
|
||||||
qup->base + QUP_OUT_FIFO_BASE);
|
qup->base + QUP_OUT_FIFO_BASE);
|
||||||
|
|
||||||
|
@ -862,10 +856,10 @@ static int qup_i2c_bam_do_xfer(struct qup_i2c_dev *qup, struct i2c_msg *msg,
|
||||||
}
|
}
|
||||||
|
|
||||||
desc_err:
|
desc_err:
|
||||||
dma_unmap_sg(qup->dev, qup->btx.sg, tx_nents, DMA_TO_DEVICE);
|
dma_unmap_sg(qup->dev, qup->btx.sg, tx_cnt, DMA_TO_DEVICE);
|
||||||
|
|
||||||
if (rx_nents)
|
if (rx_cnt)
|
||||||
dma_unmap_sg(qup->dev, qup->brx.sg, rx_nents,
|
dma_unmap_sg(qup->dev, qup->brx.sg, rx_cnt,
|
||||||
DMA_FROM_DEVICE);
|
DMA_FROM_DEVICE);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Add table
Reference in a new issue