Re: [PATCH v18 1/2] fpga: lattice-sysconfig-spi: add Lattice sysCONFIG FPGA manager

From: Xu Yilun
Date: Wed Oct 19 2022 - 01:03:33 EST


On 2022-10-14 at 23:27:49 +0300, Ivan Bornyakov wrote:
> Add support to the FPGA manager for programming Lattice ECP5 FPGA over
> slave SPI sysCONFIG interface.
>
> sysCONFIG interface core functionality is separate from both ECP5 and
> SPI specifics, so support for other FPGAs with different port types can
> be added in the future.
>
> Signed-off-by: Ivan Bornyakov <i.bornyakov@xxxxxxxxxxx>
> ---

[...]

> +static int sysconfig_poll_gpio(struct gpio_desc *gpio, bool is_active)
> +{
> + int ret, val;
> +
> + ret = read_poll_timeout(gpiod_get_value, val, val < 0 ||
> + (val && is_active) || (!val && !is_active),

val < 0 || (!!val == is_active)

is it better?

> + SYSCONFIG_POLL_INTERVAL_US,
> + SYSCONFIG_POLL_GPIO_TIMEOUT_US, false, gpio);
> +
> + return val < 0 ? val : ret;

Try not to use ternery operator here.

if (ret)
return ret;
else if (val < 0)
return val;

return 0;

Is it OK?

Thanks,
Yilun