Re: [PATCH] i2c: cgbc: Fetch the status of a write transfer

From: Thomas Richard

Date: Thu Nov 26 2026 - 15:18:19 EST


On 11/26/26 2:14 PM, Andi Shyti wrote:
> Hi Thomas and Markus,
>
>>> diff --git a/drivers/i2c/busses/i2c-cgbc.c b/drivers/i2c/busses/i2c-cgbc.c
>>> index dfdb9ffc6447..2361591a1e31 100644
>>> --- a/drivers/i2c/busses/i2c-cgbc.c
>>> +++ b/drivers/i2c/busses/i2c-cgbc.c
>>> @@ -254,6 +254,22 @@ static int cgbc_i2c_xfer_msg(struct i2c_adapter *adap)
>>> ret = cgbc_command(cgbc, &cmd, cmd_len, NULL, 0, NULL);
>>> if (ret)
>>> goto err;
>>> +
>>> + ret = read_poll_timeout(cgbc_i2c_get_status, status,
>>> + status != CGBC_I2C_STAT_BUSY, 0,
>>> + 2 * algo_data->read_maxtime_us, false, adap);
>
> would it make sense use USEC_PER_SEC here to preserve the
> existing one-second timeout between write chunks?
read_maxtime_us was computed based on the bus frequency and the maximum
amount of data that can be read by one transfer.
CGBC_I2C_WRITE_MAX_LEN is 32 whereas CGBC_I2C_READ_MAX_LEN is 31, but
multiplied by 2 we should be safe.

If I'm not mistaken, USEC_PER_SEC is only used if master_xfer returns
-EGAIN (arbitration loss), else __i2c_transfer() directly returns so no
1s timeout. And we never return -EAGAIN.

So why should we wait 1s?

Maybe I did not get your point.

Best Regards,
Thomas