diff mbox series

[02/12] i2c: xiic: Enter standard mode only for > 255 byte read transfers

Message ID 1656072327-13628-3-git-send-email-manikanta.guntupalli@xilinx.com
State New
Headers show
Series i2c: xiic: Added Standard mode and SMBus | expand

Commit Message

Manikanta Guntupalli June 24, 2022, 12:05 p.m. UTC
From: Raviteja Narayanam <raviteja.narayanam@xilinx.com>

To maintain backward compatibility the default transfer mode is dynamic
mode. Enter standard mode only when the size of read transfer is > 255
bytes.

Signed-off-by: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@xilinx.com>
---
 drivers/i2c/busses/i2c-xiic.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

Comments

Krzysztof Adamski June 29, 2022, 12:21 p.m. UTC | #1
Hi,

W dniu 24.06.2022 o 14:05, Manikanta Guntupalli pisze:
> From: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
>
> To maintain backward compatibility the default transfer mode is dynamic
> mode. Enter standard mode only when the size of read transfer is > 255
> bytes.
>
> Signed-off-by: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
> Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@xilinx.com>

[...]

I don't really understand why this patch isn't squashed into previous 
one. The previous patch was only checking the first message which was 
wrong, this one fixes that.

Krzytof
Guntupalli, Manikanta June 30, 2022, 8:06 a.m. UTC | #2
> -----Original Message-----
> From: Krzysztof Adamski <krzysztof.adamski@nokia.com>
> Sent: Wednesday, June 29, 2022 5:52 PM
> To: Manikanta Guntupalli <manikanta.guntupalli@xilinx.com>;
> michal.simek@xilinx.com; Simek, Michal <michal.simek@amd.com>; linux-
> arm-kernel@lists.infradead.org; linux-i2c@vger.kernel.org; linux-
> kernel@vger.kernel.org; git (AMD-Xilinx) <git@amd.com>
> Cc: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
> Subject: Re: [PATCH 02/12] i2c: xiic: Enter standard mode only for > 255 byte
> read transfers
> 
> CAUTION: This message has originated from an External Source. Please use
> proper judgment and caution when opening attachments, clicking links, or
> responding to this email.
> 
> 
> Hi,
> 
> W dniu 24.06.2022 o 14:05, Manikanta Guntupalli pisze:
> > From: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
> >
> > To maintain backward compatibility the default transfer mode is
> > dynamic mode. Enter standard mode only when the size of read transfer
> > is > 255 bytes.
> >
> > Signed-off-by: Raviteja Narayanam <raviteja.narayanam@xilinx.com>
> > Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli@xilinx.com>
> 
> [...]
> 
> I don't really understand why this patch isn't squashed into previous one. The
> previous patch was only checking the first message which was wrong, this
> one fixes that.

We will fix in  V2

Thanks,
Manikanta.
diff mbox series

Patch

diff --git a/drivers/i2c/busses/i2c-xiic.c b/drivers/i2c/busses/i2c-xiic.c
index fb2443623844..c8b68176427c 100644
--- a/drivers/i2c/busses/i2c-xiic.c
+++ b/drivers/i2c/busses/i2c-xiic.c
@@ -904,7 +904,7 @@  static int xiic_start_xfer(struct xiic_i2c *i2c, struct i2c_msg *msgs, int num)
 static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 {
 	struct xiic_i2c *i2c = i2c_get_adapdata(adap);
-	int err;
+	int err, count;
 
 	dev_dbg(adap->dev.parent, "%s entry SR: 0x%x\n", __func__,
 		xiic_getreg8(i2c, XIIC_SR_REG_OFFSET));
@@ -916,27 +916,12 @@  static int xiic_xfer(struct i2c_adapter *adap, struct i2c_msg *msgs, int num)
 	/* Decide standard mode or Dynamic mode */
 	i2c->dynamic = true;
 
-	/*
-	 * If number of messages is 1 and read length is > 255 bytes,
-	 * enter standard mode
-	 */
-
-	if (i2c->nmsgs == 1 && (i2c->tx_msg->flags & I2C_M_RD) &&
-	    i2c->tx_msg->len > MAX_READ_LENGTH_DYNAMIC) {
-		i2c->dynamic = false;
-	} else if (i2c->nmsgs > 1) {
-		int count;
-
-		/*
-		 * If number of messages is more than 1 and one of them is
-		 * a read message, enter standard mode. Since repeated start
-		 * operation in dynamic mode read is not happenning
-		 */
-		for (count = 0; count < i2c->nmsgs; count++) {
-			if (i2c->tx_msg[count].flags & I2C_M_RD) {
-				i2c->dynamic = false;
-				break;
-			}
+	/* Enter standard mode only when read length is > 255 bytes */
+	for (count = 0; count < i2c->nmsgs; count++) {
+		if ((i2c->tx_msg[count].flags & I2C_M_RD) &&
+		    i2c->tx_msg[count].len > MAX_READ_LENGTH_DYNAMIC) {
+			i2c->dynamic = false;
+			break;
 		}
 	}