resources/KernelSource_4_19v/drivers/fpga/fpga-mgr.c
/**
 * fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list
 * @mgr:	fpga manager
 * @info:	fpga image specific information
 * @sgt:	scatterlist table
 *
 * Step the low level fpga manager through the device-specific steps of getting
 * an FPGA ready to be configured, writing the image to it, then doing whatever
 * post-configuration steps necessary.  This code assumes the caller got the
 * mgr pointer from of_fpga_mgr_get() or fpga_mgr_get() and checked that it is
 * not an error code.
 *
 * This is the preferred entry point for FPGA programming, it does not require
 * any contiguous kernel memory.
 *
 * Return: 0 on success, negative error code otherwise.
 */
load fpga from image in buffer from a scatter list
@mgr:        fpga manager
@info:       fpga image specific information
@sgt:        scatterlist table

Step the low level fpga manager through the device-specific steps of getting
an FPGA ready to be configured, writing the image to it, then doing whatever
post-configuration steps necessary.  This code assumes the caller got the
mgr pointer from of_fpga_mgr_get() or fpga_mgr_get() and checked that it is
not an error code.

This is the preferred entry point for FPGA programming, it does not require
any contiguous kernel memory.

0 on success, negative error code otherwise.
load fpga from image in buffer from a scatter list @mgr : fpga manager @info : fpga image specific information @sgt : scatterlist table Step the low level fpga manager through the device - specific steps of getting an FPGA ready to be configured writing the image to it then doing whatever post - configuration steps necessary . This code assumes the caller got the mgr pointer from of_fpga_mgr_get () or fpga_mgr_get () and checked that it is not an error code . This is the preferred entry point for FPGA programming it does not require any contiguous kernel memory . 0 on success negative error code otherwise .
static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr,
				struct fpga_image_info *info,
				struct sg_table *sgt)
{
	int ret;
	ret = fpga_mgr_write_init_sg(mgr, info, sgt);
	if (ret)
		return ret;
	mgr->state = FPGA_MGR_STATE_WRITE;
	if (mgr->mops->write_sg) {
		ret = mgr->mops->write_sg(mgr, sgt);
	} else {
		struct sg_mapping_iter miter;
		sg_miter_start(&miter, sgt->sgl, sgt->nents, SG_MITER_FROM_SG);
		while (sg_miter_next(&miter)) {
			ret = mgr->mops->write(mgr, miter.addr, miter.length);
			if (ret)
				break;
		}
		sg_miter_stop(&miter);
	}
	if (ret) {
		dev_err(&mgr->dev, "Error while writing image data to FPGA\n");
		mgr->state = FPGA_MGR_STATE_WRITE_ERR;
		return ret;
	}
	return fpga_mgr_write_complete(mgr, info);
}
static int fpga_mgr_buf_load_sg ( struct fpga_manager * mgr , struct fpga_image_info * info , struct sg_table * sgt ) { int ret ; ret = fpga_mgr_write_init_sg ( mgr , info , sgt ) ; if ( ret ) return ret ; mgr -> state = FPGA_MGR_STATE_WRITE ; if ( mgr -> mops -> write_sg ) { ret = mgr -> mops -> write_sg ( mgr , sgt ) ; } else { struct sg_mapping_iter miter ; sg_miter_start ( & miter , sgt -> sgl , sgt -> nents , SG_MITER_FROM_SG ) ; while ( sg_miter_next ( & miter ) ) { ret = mgr -> mops -> write ( mgr , miter . addr , miter . length ) ; if ( ret ) break ; } sg_miter_stop ( & miter ) ; } if ( ret ) { dev_err ( & mgr -> dev , " \n " ) ; mgr -> state = FPGA_MGR_STATE_WRITE_ERR ; return ret ; } return fpga_mgr_write_complete ( mgr , info ) ; }
fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list
 @mgr:        fpga manager
 @info:       fpga image specific information
 @sgt:        scatterlist table
fpga_mgr_buf_load_sg - load fpga from image in buffer from a scatter list @mgr : fpga manager @info : fpga image specific information @sgt : scatterlist table
/* Write the FPGA image to the FPGA. */