Re: [PATCH v2] i2c: add support for Zhaoxin I2C controller

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> >> +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



[Index of Archives]     [Linux GPIO]     [Linux SPI]     [Linux Hardward Monitoring]     [LM Sensors]     [Linux USB Devel]     [Linux Media]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux