[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <uq6n6s4ksuxvkonowouhr747cnu4ccwvhgpl6r7txgdtnimqnz@sl33zjshzemk>
Date: Mon, 4 Mar 2024 14:54:28 +0100
From: Andi Shyti <andi.shyti@...nel.org>
To: Théo Lebrun <theo.lebrun@...tlin.com>
Cc: Linus Walleij <linus.walleij@...aro.org>,
Rob Herring <robh+dt@...nel.org>, Krzysztof Kozlowski <krzysztof.kozlowski+dt@...aro.org>,
Conor Dooley <conor+dt@...nel.org>, Thomas Bogendoerfer <tsbogend@...ha.franken.de>,
linux-arm-kernel@...ts.infradead.org, linux-i2c@...r.kernel.org, devicetree@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-mips@...r.kernel.org,
Gregory Clement <gregory.clement@...tlin.com>, Vladimir Kondratiev <vladimir.kondratiev@...ileye.com>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>, Tawfik Bayouk <tawfik.bayouk@...ileye.com>
Subject: Re: [SPAM] [PATCH v2 06/11] i2c: nomadik: support short xfer
timeouts using waitqueue & hrtimer
Hi Theo,
..
> +static bool nmk_i2c_wait_xfer_done(struct nmk_i2c_dev *priv)
> +{
> + if (priv->timeout_usecs < jiffies_to_usecs(1)) {
> + unsigned long timeout_usecs = priv->timeout_usecs;
> + ktime_t timeout = ktime_set(0, timeout_usecs * NSEC_PER_USEC);
> +
> + wait_event_hrtimeout(priv->xfer_wq, priv->xfer_done, timeout);
> + } else {
> + unsigned long timeout = usecs_to_jiffies(priv->timeout_usecs);
> +
> + wait_event_timeout(priv->xfer_wq, priv->xfer_done, timeout);
> + }
> +
> + return priv->xfer_done;
You could eventually write this as
static bool nmk_i2c_wait_xfer_done(struct nmk_i2c_dev *priv)
{
if (priv->timeout_usecs < jiffies_to_usecs(1)) {
...
return !wait_event_hrtimeout(...);
}
...
return wait_event_timeout(...);
}
It looks a bit cleaner to me... your choice.
Rest looks good.
Reviewed-by: Andi Shyti <andi.shyti@...nel.org>
Andi
Powered by blists - more mailing lists