From: Andi Shyti <andi.shyti@kernel.org>
To: HansHu-oc <HansHu-oc@zhaoxin.com>
Cc: "jdelvare@suse.com" <jdelvare@suse.com>,
"wsa@kernel.org" <wsa@kernel.org>,
"linux-i2c@vger.kernel.org" <linux-i2c@vger.kernel.org>,
"Cobe Chen(BJ-RD)" <CobeChen@zhaoxin.com>,
"Tony W. Wang(XA-RD)" <TonyWWang@zhaoxin.com>
Subject: Re: [PATCH v2] i2c: add support for Zhaoxin I2C controller
Date: Thu, 1 Jun 2023 11:31:48 +0200 [thread overview]
Message-ID: <20230601093148.ycacijzq7ksbgqjy@intel.intel> (raw)
In-Reply-To: <3509ba04d98b4537ba3459407da43f62@zhaoxin.com>
> >> +static int zxi2c_wait_event(struct zxi2c *i2c, u8 event)
> >> +{
> >> + int timeout;
> >> +
> >> + timeout = wait_event_interruptible_timeout(i2c->waitq,
> >> + i2c->event != 0,
> >> + msecs_to_jiffies(ZXI2C_TIMEOUT));
> >> +
> >> + if (i2c->event & event)
> >> + return 0;
> >
> > is this valid even when "timeout == 0"?
>
> Let's see the description of the value returned by wait_event_interruptible_timeout():
> https://elixir.bootlin.com/linux/v6.3.5/source/include/linux/wait.h#L525
> * Returns:
> * 0 if the @condition evaluated to %false after the @timeout elapsed,
> * 1 if the @condition evaluated to %true after the @timeout elapsed,
> * the remaining jiffies (at least 1) if the @condition evaluated
> * to %true before the @timeout elapsed, or -%ERESTARTSYS if it was
> * interrupted by a signal.
yes, I know, that's why I asked.
> So, "timeout == 0" and @condition evaluated to %true unlikely to happen at the same time.
unlikely is a very strong word and rearrangement is free. So,
based on what you copy pasted above, I would first put the
"timeout == 0" check and then the rest.
Andi
next prev parent reply other threads:[~2023-06-01 9:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-01 6:37 [PATCH v2] i2c: add support for Zhaoxin I2C controller HansHu-oc
2023-06-01 9:31 ` Andi Shyti [this message]
-- strict thread matches above, loose matches on Subject: below --
2023-05-29 7:31 Hans Hu
2023-05-31 11:00 ` Andi Shyti
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=20230601093148.ycacijzq7ksbgqjy@intel.intel \
--to=andi.shyti@kernel.org \
--cc=CobeChen@zhaoxin.com \
--cc=HansHu-oc@zhaoxin.com \
--cc=TonyWWang@zhaoxin.com \
--cc=jdelvare@suse.com \
--cc=linux-i2c@vger.kernel.org \
--cc=wsa@kernel.org \
/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