mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mukesh Savaliya <mukesh.savaliya@oss.qualcomm.com>
To: Aniket Randive <aniket.randive@oss.qualcomm.com>,
	Wolfram Sang <wsa+renesas@sang-engineering.com>,
	Andi Shyti <andi.shyti@kernel.org>,
	Dmitry Guzman <Dmitry.Guzman@mobileye.com>
Cc: Viken Dadhaniya <viken.dadhaniya@oss.qualcomm.com>,
	linux-i2c@vger.kernel.org, linux-arm-msm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 1/2] i2c: core: Add i2c_update_timeout() helper for dynamic transfer timeouts
Date: Mon, 24 Aug 2026 11:49:44 +0530	[thread overview]
Message-ID: <29719c5f-757d-426e-94ca-c221f45c00cf@oss.qualcomm.com> (raw)
In-Reply-To: <20260813-master-v7-1-3f9010cf9229@oss.qualcomm.com>



On 8/13/2026 11:15 AM, Aniket Randive wrote:
[...]

> +void i2c_update_timeout(struct i2c_adapter *adap, u32 bus_freq_hz,
> +			size_t len, unsigned int safety_coeff,
> +			unsigned int min_usec)
> +{
> +	u64 bit_usec = mul_u64_u32_div(len * 9, USEC_PER_SEC, bus_freq_hz);
let's validate bus_freq_hz to prevent from 0 value in case of any 
abnormal caller.

> +	u64 total_usec = bit_usec * safety_coeff + min_usec;
> +	unsigned long jiffies_val;
> +
> +	/* Userspace-configured timeout always takes precedence. */
> +	if (adap->user_timeout > 0) {
> +		adap->timeout = adap->user_timeout;
> +		return;
> +	}
> +
> +	jiffies_val = usecs_to_jiffies((unsigned int)min_t(u64, total_usec, UINT_MAX));
> +	/* adap->timeout is int; guard against signed overflow. */
> +	adap->timeout = (int)min_t(unsigned long, jiffies_val, INT_MAX);
> +}
> +EXPORT_SYMBOL_GPL(i2c_update_timeout);
> +#endif /* CONFIG_I2C_DYNAMIC_TIMEOUT */
> +

[...]


  reply	other threads:[~2026-08-24  6:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-13  5:45 [PATCH v7 0/2] i2c: Add dynamic transfer timeout based on message length and frequency Aniket Randive
2026-08-13  5:45 ` [PATCH v7 1/2] i2c: core: Add i2c_update_timeout() helper for dynamic transfer timeouts Aniket Randive
2026-08-24  6:19   ` Mukesh Savaliya [this message]
2026-08-24 10:06     ` Aniket RANDIVE
2026-08-24 13:44       ` Mukesh Savaliya
2026-08-26 10:51         ` Aniket RANDIVE
2026-08-13  5:45 ` [PATCH v7 2/2] i2c: qcom-geni: Add dynamic transfer timeout based on transfer length and frequency Aniket Randive
2026-08-24  7:11   ` Mukesh Savaliya
2026-08-26 10:49     ` Aniket RANDIVE

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=29719c5f-757d-426e-94ca-c221f45c00cf@oss.qualcomm.com \
    --to=mukesh.savaliya@oss.qualcomm.com \
    --cc=Dmitry.Guzman@mobileye.com \
    --cc=andi.shyti@kernel.org \
    --cc=aniket.randive@oss.qualcomm.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-i2c@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viken.dadhaniya@oss.qualcomm.com \
    --cc=wsa+renesas@sang-engineering.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®