linux/drivers/fpga/of-fpga-region.c
/**
 * of_fpga_region_parse_ov - parse and check overlay applied to region
 *
 * @region: FPGA region
 * @overlay: overlay applied to the FPGA region
 *
 * Given an overlay applied to a FPGA region, parse the FPGA image specific
 * info in the overlay and do some checking.
 *
 * Returns:
 *   NULL if overlay doesn't direct us to program the FPGA.
 *   fpga_image_info struct if there is an image to program.
 *   error code for invalid overlay.
 */
parse and check overlay applied to region
@region: FPGA region
@overlay: overlay applied to the FPGA region

Given an overlay applied to a FPGA region, parse the FPGA image specific
info in the overlay and do some checking.

NULL if overlay doesn't direct us to program the FPGA.
fpga_image_info struct if there is an image to program.
error code for invalid overlay.
parse and check overlay applied to region @region : FPGA region @overlay : overlay applied to the FPGA region Given an overlay applied to a FPGA region parse the FPGA image specific info in the overlay and do some checking . NULL if overlay doesn ' t direct us to program the FPGA . fpga_image_info struct if there is an image to program . error code for invalid overlay .
static struct fpga_image_info *of_fpga_region_parse_ov(
						struct fpga_region *region,
						struct device_node *overlay)
{
	struct device *dev = &region->dev;
	struct fpga_image_info *info;
	const char *firmware_name;
	int ret;
	if (region->info) {
		dev_err(dev, "Region already has overlay applied.\n");
		return ERR_PTR(-EINVAL);
	}
	ret = child_regions_with_firmware(overlay);
	if (ret)
		return ERR_PTR(ret);
	info = fpga_image_info_alloc(dev);
	if (!info)
		return ERR_PTR(-ENOMEM);
	info->overlay = overlay;
	if (of_property_read_bool(overlay, "partial-fpga-config"))
		info->flags |= FPGA_MGR_PARTIAL_RECONFIG;
	if (of_property_read_bool(overlay, "external-fpga-config"))
		info->flags |= FPGA_MGR_EXTERNAL_CONFIG;
	if (of_property_read_bool(overlay, "encrypted-fpga-config"))
		info->flags |= FPGA_MGR_ENCRYPTED_BITSTREAM;
	if (!of_property_read_string(overlay, "firmware-name",
				     &firmware_name)) {
		info->firmware_name = devm_kstrdup(dev, firmware_name,
						   GFP_KERNEL);
		if (!info->firmware_name)
			return ERR_PTR(-ENOMEM);
	}
	of_property_read_u32(overlay, "region-unfreeze-timeout-us",
			     &info->enable_timeout_us);
	of_property_read_u32(overlay, "region-freeze-timeout-us",
			     &info->disable_timeout_us);
	of_property_read_u32(overlay, "config-complete-timeout-us",
			     &info->config_complete_timeout_us);
	if (!info->firmware_name) {
		ret = 0;
		goto ret_no_info;
	}
	if (info->flags & FPGA_MGR_EXTERNAL_CONFIG) {
		dev_err(dev, "error: specified firmware and external-fpga-config");
		ret = -EINVAL;
		goto ret_no_info;
	}
	return info;
ret_no_info:
	fpga_image_info_free(info);
	return ERR_PTR(ret);
}
static struct fpga_image_info * of_fpga_region_parse_ov ( struct fpga_region * region , struct device_node * overlay ) { struct device * dev = & region -> dev ; struct fpga_image_info * info ; const char * firmware_name ; int ret ; if ( region -> info ) { dev_err ( dev , " \n " ) ; return ERR_PTR ( - EINVAL ) ; } ret = child_regions_with_firmware ( overlay ) ; if ( ret ) return ERR_PTR ( ret ) ; info = fpga_image_info_alloc ( dev ) ; if ( ! info ) return ERR_PTR ( - ENOMEM ) ; info -> overlay = overlay ; if ( of_property_read_bool ( overlay , " " ) ) info -> flags |= FPGA_MGR_PARTIAL_RECONFIG ; if ( of_property_read_bool ( overlay , " " ) ) info -> flags |= FPGA_MGR_EXTERNAL_CONFIG ; if ( of_property_read_bool ( overlay , " " ) ) info -> flags |= FPGA_MGR_ENCRYPTED_BITSTREAM ; if ( ! of_property_read_string ( overlay , " " , & firmware_name ) ) { info -> firmware_name = devm_kstrdup ( dev , firmware_name , GFP_KERNEL ) ; if ( ! info -> firmware_name ) return ERR_PTR ( - ENOMEM ) ; } of_property_read_u32 ( overlay , " " , & info -> enable_timeout_us ) ; of_property_read_u32 ( overlay , " " , & info -> disable_timeout_us ) ; of_property_read_u32 ( overlay , " " , & info -> config_complete_timeout_us ) ; if ( ! info -> firmware_name ) { ret = 0 ; goto ret_no_info ; } if ( info -> flags & FPGA_MGR_EXTERNAL_CONFIG ) { dev_err ( dev , " " ) ; ret = - EINVAL ; goto ret_no_info ; } return info ; ret_no_info : fpga_image_info_free ( info ) ; return ERR_PTR ( ret ) ; }
of_fpga_region_parse_ov - parse and check overlay applied to region
 @region: FPGA region
 @overlay: overlay applied to the FPGA region
of_fpga_region_parse_ov - parse and check overlay applied to region @region : FPGA region @overlay : overlay applied to the FPGA region
/*
	 * Reject overlay if child FPGA Regions added in the overlay have
	 * firmware-name property (would mean that an FPGA region that has
	 * not been added to the live tree yet is doing FPGA programming).
	 */ /* Read FPGA region properties from the overlay */ /* If overlay is not programming the FPGA, don't need FPGA image info */ /*
	 * If overlay informs us FPGA was externally programmed, specifying
	 * firmware here would be ambiguous.
	 */