[PATCH v9 05/13] fpga: add fpga_compatible2flag

Michal Simek michal.simek at xilinx.com
Tue Jun 7 14:11:27 CEST 2022



On 6/1/22 10:46, Oleksandr Suvorov wrote:
> Add a "compatible" string to binary flag converter, which uses
> a callback str2flag() of given FPGA driver if available.
> 
> Signed-off-by: Oleksandr Suvorov <oleksandr.suvorov at foundries.io>
> ---
> 
> (no changes since v1)
> 
>   drivers/fpga/fpga.c | 26 ++++++++++++++++++++++++++
>   include/fpga.h      |  1 +
>   2 files changed, 27 insertions(+)
> 
> diff --git a/drivers/fpga/fpga.c b/drivers/fpga/fpga.c
> index 3b0a44b2420..fbfdd406e3b 100644
> --- a/drivers/fpga/fpga.c
> +++ b/drivers/fpga/fpga.c
> @@ -356,3 +356,29 @@ int fpga_info(int devnum)
>   
>   	return fpga_dev_info(devnum);
>   }
> +
> +int fpga_compatible2flag(int devnum, const char *compatible)
> +{
> +	const fpga_desc * const desc = fpga_get_desc(devnum);
> +
> +	if (!desc)
> +		return FPGA_FAIL;
> +
> +	switch (desc->devtype) {
> +	case fpga_xilinx:
> +#if defined(CONFIG_FPGA_XILINX)
> +	{
> +		xilinx_desc *xdesc = (xilinx_desc *)desc->devdesc;
> +
> +		if (xdesc->operations->str2flag)
> +			return xdesc->operations->str2flag(xdesc, compatible);

This function is returning FPGA_FAIL or 0 (FPGA_SUCCESS) but str2flag is 
returning based on 4/14 flags.

It means you are mixing two things here together.

Thanks,
Michal


More information about the U-Boot mailing list