diff options
author | Tom Rix <trix@redhat.com> | 2021-06-25 21:51:46 +0200 |
---|---|---|
committer | Moritz Fischer <mdf@kernel.org> | 2021-07-25 00:10:31 +0200 |
commit | b02a40713db95ebd8f72151b0fea8080d9f74c27 (patch) | |
tree | 03f2053a8e68225b35793f8c9c37e40df16d1289 /drivers/fpga/fpga-mgr.c | |
parent | fpga: fpga-mgr: wrap the status() op (diff) | |
download | linux-b02a40713db95ebd8f72151b0fea8080d9f74c27.tar.xz linux-b02a40713db95ebd8f72151b0fea8080d9f74c27.zip |
fpga: fpga-mgr: wrap the state() op
An FPGA manager should not be required to provide a state() op.
Add a wrapper consistent with the other op wrappers.
Move op check to wrapper.
Default to FPGA_MGR_STATE_UNKNOWN, what noop state() ops use.
Remove unneeded noop state() ops
[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/fpga-mgr.c')
-rw-r--r-- | drivers/fpga/fpga-mgr.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index 43518b6eed21..b3380ad341d2 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 enum fpga_mgr_states fpga_mgr_state(struct fpga_manager *mgr) +{ + if (mgr->mops->state) + return mgr->mops->state(mgr); + return FPGA_MGR_STATE_UNKNOWN; +} + static inline u64 fpga_mgr_status(struct fpga_manager *mgr) { if (mgr->mops->status) @@ -589,7 +596,7 @@ struct fpga_manager *fpga_mgr_create(struct device *parent, const char *name, struct fpga_manager *mgr; int id, ret; - if (!mops || !mops->state) { + if (!mops) { dev_err(parent, "Attempt to register without fpga_manager_ops\n"); return NULL; } @@ -707,7 +714,7 @@ int fpga_mgr_register(struct fpga_manager *mgr) * from device. FPGA may be in reset mode or may have been programmed * by bootloader or EEPROM. */ - mgr->state = mgr->mops->state(mgr); + mgr->state = fpga_mgr_state(mgr); ret = device_add(&mgr->dev); if (ret) |