diff options
author | Wu Hao <hao.wu@intel.com> | 2018-06-29 20:53:10 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2018-07-15 07:55:44 -0400 |
commit | ecb5fbe299dfaad778033259f35bc696fa1fb743 (patch) | |
tree | 6a3db26d67f707197718d8b772f19fbca8fe8e5c /drivers/fpga | |
parent | 571d78bd458a831cf51dff2afa1dda3309bd82b2 (diff) |
fpga: mgr: add status for fpga-manager
This patch adds status sysfs interface for fpga manager, it's a
read only interface which allows user to get fpga manager status,
including full/partial reconfiguration error and other status
information. It adds a status callback to fpga_manager_ops too,
allows each fpga_manager driver to define its own method to
collect latest status from hardware.
The following sysfs file is created:
* /sys/class/fpga_manager/<fpga>/status
Return status of fpga manager, including reconfiguration errors.
Signed-off-by: Wu Hao <hao.wu@intel.com>
Acked-by: Alan Tull <atull@kernel.org>
Acked-by: Moritz Fischer <mdf@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/fpga')
-rw-r--r-- | drivers/fpga/fpga-mgr.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c index c1564cf827fe..a41b07e37884 100644 --- a/drivers/fpga/fpga-mgr.c +++ b/drivers/fpga/fpga-mgr.c | |||
@@ -406,12 +406,40 @@ static ssize_t state_show(struct device *dev, | |||
406 | return sprintf(buf, "%s\n", state_str[mgr->state]); | 406 | return sprintf(buf, "%s\n", state_str[mgr->state]); |
407 | } | 407 | } |
408 | 408 | ||
409 | static ssize_t status_show(struct device *dev, | ||
410 | struct device_attribute *attr, char *buf) | ||
411 | { | ||
412 | struct fpga_manager *mgr = to_fpga_manager(dev); | ||
413 | u64 status; | ||
414 | int len = 0; | ||
415 | |||
416 | if (!mgr->mops->status) | ||
417 | return -ENOENT; | ||
418 | |||
419 | status = mgr->mops->status(mgr); | ||
420 | |||
421 | if (status & FPGA_MGR_STATUS_OPERATION_ERR) | ||
422 | len += sprintf(buf + len, "reconfig operation error\n"); | ||
423 | if (status & FPGA_MGR_STATUS_CRC_ERR) | ||
424 | len += sprintf(buf + len, "reconfig CRC error\n"); | ||
425 | if (status & FPGA_MGR_STATUS_INCOMPATIBLE_IMAGE_ERR) | ||
426 | len += sprintf(buf + len, "reconfig incompatible image\n"); | ||
427 | if (status & FPGA_MGR_STATUS_IP_PROTOCOL_ERR) | ||
428 | len += sprintf(buf + len, "reconfig IP protocol error\n"); | ||
429 | if (status & FPGA_MGR_STATUS_FIFO_OVERFLOW_ERR) | ||
430 | len += sprintf(buf + len, "reconfig fifo overflow error\n"); | ||
431 | |||
432 | return len; | ||
433 | } | ||
434 | |||
409 | static DEVICE_ATTR_RO(name); | 435 | static DEVICE_ATTR_RO(name); |
410 | static DEVICE_ATTR_RO(state); | 436 | static DEVICE_ATTR_RO(state); |
437 | static DEVICE_ATTR_RO(status); | ||
411 | 438 | ||
412 | static struct attribute *fpga_mgr_attrs[] = { | 439 | static struct attribute *fpga_mgr_attrs[] = { |
413 | &dev_attr_name.attr, | 440 | &dev_attr_name.attr, |
414 | &dev_attr_state.attr, | 441 | &dev_attr_state.attr, |
442 | &dev_attr_status.attr, | ||
415 | NULL, | 443 | NULL, |
416 | }; | 444 | }; |
417 | ATTRIBUTE_GROUPS(fpga_mgr); | 445 | ATTRIBUTE_GROUPS(fpga_mgr); |