dnsmasq: full: disable ipset support by default
[openwrt/staging/mkresin.git] / target / linux / ipq40xx / patches-4.14 / 088-0003-i2c-qup-minor-code-reorganization-for-use_dma.patch
1 From eb422b539c1f39faf576826b54be93e84d9cb32a Mon Sep 17 00:00:00 2001
2 From: Abhishek Sahu <absahu@codeaurora.org>
3 Date: Mon, 12 Mar 2018 18:44:52 +0530
4 Subject: [PATCH 03/13] i2c: qup: minor code reorganization for use_dma
5
6 1. Assigns use_dma in qup_dev structure itself which will
7 help in subsequent patches to determine the mode in IRQ handler.
8 2. Does minor code reorganization for loops to reduce the
9 unnecessary comparison and assignment.
10
11 Signed-off-by: Abhishek Sahu <absahu@codeaurora.org>
12 Reviewed-by: Austin Christ <austinwc@codeaurora.org>
13 Reviewed-by: Andy Gross <andy.gross@linaro.org>
14 Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
15 ---
16 drivers/i2c/busses/i2c-qup.c | 19 +++++++++++--------
17 1 file changed, 11 insertions(+), 8 deletions(-)
18
19 --- a/drivers/i2c/busses/i2c-qup.c
20 +++ b/drivers/i2c/busses/i2c-qup.c
21 @@ -181,6 +181,8 @@ struct qup_i2c_dev {
22
23 /* dma parameters */
24 bool is_dma;
25 + /* To check if the current transfer is using DMA */
26 + bool use_dma;
27 struct dma_pool *dpool;
28 struct qup_i2c_tag start_tag;
29 struct qup_i2c_bam brx;
30 @@ -1288,7 +1290,7 @@ static int qup_i2c_xfer_v2(struct i2c_ad
31 int num)
32 {
33 struct qup_i2c_dev *qup = i2c_get_adapdata(adap);
34 - int ret, len, idx = 0, use_dma = 0;
35 + int ret, len, idx = 0;
36
37 qup->bus_err = 0;
38 qup->qup_err = 0;
39 @@ -1317,13 +1319,12 @@ static int qup_i2c_xfer_v2(struct i2c_ad
40 len = (msgs[idx].len > qup->out_fifo_sz) ||
41 (msgs[idx].len > qup->in_fifo_sz);
42
43 - if ((!is_vmalloc_addr(msgs[idx].buf)) && len) {
44 - use_dma = 1;
45 - } else {
46 - use_dma = 0;
47 + if (is_vmalloc_addr(msgs[idx].buf) || !len)
48 break;
49 - }
50 }
51 +
52 + if (idx == num)
53 + qup->use_dma = true;
54 }
55
56 idx = 0;
57 @@ -1347,15 +1348,17 @@ static int qup_i2c_xfer_v2(struct i2c_ad
58
59 reinit_completion(&qup->xfer);
60
61 - if (use_dma) {
62 + if (qup->use_dma) {
63 ret = qup_i2c_bam_xfer(adap, &msgs[idx], num);
64 + qup->use_dma = false;
65 + break;
66 } else {
67 if (msgs[idx].flags & I2C_M_RD)
68 ret = qup_i2c_read_one_v2(qup, &msgs[idx]);
69 else
70 ret = qup_i2c_write_one_v2(qup, &msgs[idx]);
71 }
72 - } while ((idx++ < (num - 1)) && !use_dma && !ret);
73 + } while ((idx++ < (num - 1)) && !ret);
74
75 if (!ret)
76 ret = qup_i2c_change_state(qup, QUP_RESET_STATE);