diff options
author | Tom Rix <trix@redhat.com> | 2021-06-25 12:51:45 -0700 |
---|---|---|
committer | Moritz Fischer <mdf@kernel.org> | 2021-07-24 15:10:31 -0700 |
commit | 6f9922711359d2092fb91036193dfed0d1bdf8b8 (patch) | |
tree | 3399a191b3f305f3f475d2c512d493f48dd578c4 /drivers/fpga | |
parent | 8ebab40fd8f1683140890a77fadf571db98686b8 (diff) |
fpga: fpga-mgr: wrap the status() op
An FPGA manager is not required to provide a status() op.
Add a wrapper consistent with the other op wrappers.
Move the op check to the wrapper.
Default to 0, no errors to report.
[mdf@kernel.org: Reworded first line]
Signed-off-by: Tom Rix <trix@redhat.com>
Signed-off-by: Moritz Fischer <mdf@kernel.org>
Diffstat (limited to 'drivers/fpga')
-rw-r--r-- | drivers/fpga/fpga-mgr.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 8d5536d74808..43518b6eed21 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c @@ -25,6 +25,13 @@ struct fpga_mgr_devres { struct fpga_manager *mgr; }; +static inline u64 fpga_mgr_status(struct fpga_manager *mgr) +{ + if (mgr->mops->status) + return mgr->mops->status(mgr); + return 0; +} + static inline int fpga_mgr_write(struct fpga_manager *mgr, const char *buf, size_t count) { if (mgr->mops->write) @@ -434,10 +441,7 @@ static ssize_t status_show(struct device *dev, u64 status; int len = 0; - if (!mgr->mops->status) - return -ENOENT; - - status = mgr->mops->status(mgr); + status = fpga_mgr_status(mgr); if (status & FPGA_MGR_STATUS_OPERATION_ERR) len += sprintf(buf + len, "reconfig operation error\n"); |