Skip to content

Commit

Permalink
fpga: fpga-mgr: wrap the write_sg() op
Browse files Browse the repository at this point in the history
An FPGA manager should not be required to provide a
write_sg function. Move the op check to the wrapper.
Default to -EOPNOTSUP so its users will fail
gracefully.

[[email protected]: Reworded first line]
Signed-off-by: Tom Rix <[email protected]>
Signed-off-by: Moritz Fischer <[email protected]>
  • Loading branch information
Tom Rix authored and mfischer committed Jul 24, 2021
1 parent 6489d3b commit 630211a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion drivers/fpga/fpga-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,14 @@ static inline int fpga_mgr_write_init(struct fpga_manager *mgr,
return 0;
}

static inline int fpga_mgr_write_sg(struct fpga_manager *mgr,
struct sg_table *sgt)
{
if (mgr->mops->write_sg)
return mgr->mops->write_sg(mgr, sgt);
return -EOPNOTSUPP;
}

/**
* fpga_image_info_alloc - Allocate an FPGA image info struct
* @dev: owning device
Expand Down Expand Up @@ -225,7 +233,7 @@ static int fpga_mgr_buf_load_sg(struct fpga_manager *mgr,
/* Write the FPGA image to the FPGA. */
mgr->state = FPGA_MGR_STATE_WRITE;
if (mgr->mops->write_sg) {
ret = mgr->mops->write_sg(mgr, sgt);
ret = fpga_mgr_write_sg(mgr, sgt);
} else {
struct sg_mapping_iter miter;

Expand Down

0 comments on commit 630211a

Please sign in to comment.