RE: [PATCH] i2c-tools: i2ctransfer: Set I2C adapter timeout using I2C_TIMEOUT ioctl

"Tandra, Vasantha Likitha" <[email protected]> Tue, 21 Jul 2026 05:17:47 +0000
Newsgroups org.kernel.vger.linux-i2c
Message-ID <DM4PR12MB77657106776BE150FDCCF7C093C22@DM4PR12MB7765.namprd12.prod.outlook.com>
AMD General

Hi Wolfram,

  Thanks for the review. Your suggestion makes sense to me - I'll move it out of i2ctransfer and add -T (timeout) and -R (retries) to i2cdetect instead. I agree a separate i2cconfig tool is
  not needed.

  While checking the list of ioctls, I observed the I2C_TIMEOUT ioctl to set the timeout, but I did not observe any "get" ioctl to read the timeout value back from user space (same for
  retries). So setting a value with -T/-R works, but reading the current value (when no value is given) does not seem possible right now.

  Could you let me know how you would like me to handle this - should I keep -T/-R as set-only for now?

  Thanks,
  Vasantha Likitha

-----Original Message-----
From: Wolfram Sang <[email protected]>
Sent: Tuesday, July 21, 2026 3:41 AM
To: Tandra, Vasantha Likitha <[email protected]>
Cc: [email protected]; [email protected]; git (AMD-Xilinx) <[email protected]>
Subject: Re: [PATCH] i2c-tools: i2ctransfer: Set I2C adapter timeout using I2C_TIMEOUT ioctl

Hi,

thank you for this patch!

On Mon, Jul 20, 2026 at 10:04:01PM +0530, Vasantha Likitha T wrote:
> Add a -t TIMEOUT option that calls ioctl(I2C_TIMEOUT) before the
> I2C_RDWR transfer. This allows the adapter timeout to be set from user
> space at runtime, controlling how long the I2C core waits for a
> transfer to complete before returning an error. Drivers that rely on
> the adapter timeout will use the value set by this ioctl.
>
> The timeout value is specified in units of 10 ms, as this is the unit
> the Linux kernel expects for the I2C_TIMEOUT ioctl: i2c-dev converts
> it with adapter->timeout = msecs_to_jiffies(arg * 10). Omitting -t
> leaves the driver default unchanged.

I agree that reading/setting TIMEOUT is missing in i2c-tools (same with
RETRIES) and it would be nice to have.

I don't think 'i2ctransfer' is the right place for it, though. One might also want a different timeout with 'i2cget' or so.

My suggestion is to add it to 'i2cdetect'. It already has '-F' to list the features of an adapter. We could add '-T' to read the timeout value and '-R' to read the retries value. If '-T' or '-R' parameters also contain a value, then this value will be written to the adapter.

Was this undestandable? Do you agree?

Another option would be to write a dedicated tool ('i2cconfig'?) for handling extra parameters, but it feels a bit bloated IMHO.

Opinions?

All the best,

   Wolfram