[PATCH 02/12] i2c: xiic: Enter standard mode only for > 255 byte read transfers
Manikanta Guntupalli
manikanta.guntupalli at xilinx.com
Fri Jun 24 05:05:17 PDT 2022
From: Raviteja Narayanam <raviteja.narayanam at 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 at xilinx.com>
Signed-off-by: Manikanta Guntupalli <manikanta.guntupalli at xilinx.com>
---
drivers/i2c/busses/i2c-xiic.c | 29 +++++++----------------------
1 file changed, 7 insertions(+), 22 deletions(-)
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;
}
}
--
2.25.1
More information about the linux-arm-kernel
mailing list