linux-mips
[Top] [All Lists]

[RFC V2 06/12] i2c: cpm: make use of the new infrastructure for quirks

To: linux-i2c@vger.kernel.org
Subject: [RFC V2 06/12] i2c: cpm: make use of the new infrastructure for quirks
From: Wolfram Sang <wsa@the-dreams.de>
Date: Wed, 25 Feb 2015 17:01:57 +0100
Cc: linux-arm-kernel@lists.infradead.org, linuxppc-dev@lists.ozlabs.org, linux-mips@linux-mips.org, Benjamin Herrenschmidt <benh@kernel.crashing.org>, Ludovic Desroches <ludovic.desroches@atmel.com>, Yingjoe Chen <yingjoe.chen@mediatek.com>, Eddie Huang <eddie.huang@mediatek.com>, Wolfram Sang <wsa@the-dreams.de>, Jochen Friedrich <jochen@scram.de>, linux-kernel@vger.kernel.org
In-reply-to: <1424880126-15047-1-git-send-email-wsa@the-dreams.de>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1424880126-15047-1-git-send-email-wsa@the-dreams.de>
Sender: linux-mips-bounce@linux-mips.org
From: Wolfram Sang <wsa+renesas@sang-engineering.com>

Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
---
 drivers/i2c/busses/i2c-cpm.c | 20 +++++++++-----------
 1 file changed, 9 insertions(+), 11 deletions(-)

diff --git a/drivers/i2c/busses/i2c-cpm.c b/drivers/i2c/busses/i2c-cpm.c
index 2d466538b2e2c9..714bdc837769fd 100644
--- a/drivers/i2c/busses/i2c-cpm.c
+++ b/drivers/i2c/busses/i2c-cpm.c
@@ -308,22 +308,12 @@ static int cpm_i2c_xfer(struct i2c_adapter *adap, struct 
i2c_msg *msgs, int num)
        struct i2c_reg __iomem *i2c_reg = cpm->i2c_reg;
        struct i2c_ram __iomem *i2c_ram = cpm->i2c_ram;
        struct i2c_msg *pmsg;
-       int ret, i;
+       int ret;
        int tptr;
        int rptr;
        cbd_t __iomem *tbdf;
        cbd_t __iomem *rbdf;
 
-       if (num > CPM_MAXBD)
-               return -EINVAL;
-
-       /* Check if we have any oversized READ requests */
-       for (i = 0; i < num; i++) {
-               pmsg = &msgs[i];
-               if (pmsg->len >= CPM_MAX_READ)
-                       return -EINVAL;
-       }
-
        /* Reset to use first buffer */
        out_be16(&i2c_ram->rbptr, in_be16(&i2c_ram->rbase));
        out_be16(&i2c_ram->tbptr, in_be16(&i2c_ram->tbase));
@@ -424,10 +414,18 @@ static const struct i2c_algorithm cpm_i2c_algo = {
        .functionality = cpm_i2c_func,
 };
 
+/* CPM_MAX_READ is also limiting writes according to the code! */
+static struct i2c_adapter_quirks cpm_i2c_quirks = {
+       .max_num_msgs = CPM_MAXBD,
+       .max_read_len = CPM_MAX_READ,
+       .max_write_len = CPM_MAX_READ,
+};
+
 static const struct i2c_adapter cpm_ops = {
        .owner          = THIS_MODULE,
        .name           = "i2c-cpm",
        .algo           = &cpm_i2c_algo,
+       .quirks         = &cpm_i2c_quirks,
 };
 
 static int cpm_i2c_setup(struct cpm_i2c *cpm)
-- 
2.1.4


<Prev in Thread] Current Thread [Next in Thread>