2022-06-24 12:08:06

by Manikanta Guntupalli

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

From: Raviteja Narayanam <[email protected]>

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 <[email protected]>
Signed-off-by: Manikanta Guntupalli <[email protected]>
---
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


2022-06-29 13:15:08

by Krzysztof Adamski

[permalink] [raw]
Subject: Re: [PATCH 02/12] i2c: xiic: Enter standard mode only for > 255 byte read transfers

Hi,

W dniu 24.06.2022 o 14:05, Manikanta Guntupalli pisze:
> From: Raviteja Narayanam <[email protected]>
>
> 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 <[email protected]>
> Signed-off-by: Manikanta Guntupalli <[email protected]>

[...]

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

2022-06-30 08:10:14

by Manikanta Guntupalli

[permalink] [raw]
Subject: RE: [PATCH 02/12] i2c: xiic: Enter standard mode only for > 255 byte read transfers



> -----Original Message-----
> From: Krzysztof Adamski <[email protected]>
> Sent: Wednesday, June 29, 2022 5:52 PM
> To: Manikanta Guntupalli <[email protected]>;
> [email protected]; Simek, Michal <[email protected]>; linux-
> [email protected]; [email protected]; linux-
> [email protected]; git (AMD-Xilinx) <[email protected]>
> Cc: Raviteja Narayanam <[email protected]>
> 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 <[email protected]>
> >
> > 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 <[email protected]>
> > Signed-off-by: Manikanta Guntupalli <[email protected]>
>
> [...]
>
> 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.