Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

fpga: region: add compat_id support

This patch introduces a compat_id pointer member and sysfs interface
for each fpga region, similar as compat_id for fpga manager, it allows
applications to read the per region compat_id for compatibility
checking before other actions on this fpga-region (e.g. PR).

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>

authored by

Wu Hao and committed by
Greg Kroah-Hartman
41a8b2c5 99a560bd

+33
+9
Documentation/ABI/testing/sysfs-class-fpga-region
··· 1 + What: /sys/class/fpga_region/<region>/compat_id 2 + Date: June 2018 3 + KernelVersion: 4.19 4 + Contact: Wu Hao <hao.wu@intel.com> 5 + Description: FPGA region id for compatibility check, e.g. compatibility 6 + of the FPGA reconfiguration hardware and image. This value 7 + is defined or calculated by the layer that is creating the 8 + FPGA region. This interface returns the compat_id value or 9 + just error code -ENOENT in case compat_id is not used.
+22
drivers/fpga/fpga-region.c
··· 158 158 } 159 159 EXPORT_SYMBOL_GPL(fpga_region_program_fpga); 160 160 161 + static ssize_t compat_id_show(struct device *dev, 162 + struct device_attribute *attr, char *buf) 163 + { 164 + struct fpga_region *region = to_fpga_region(dev); 165 + 166 + if (!region->compat_id) 167 + return -ENOENT; 168 + 169 + return sprintf(buf, "%016llx%016llx\n", 170 + (unsigned long long)region->compat_id->id_h, 171 + (unsigned long long)region->compat_id->id_l); 172 + } 173 + 174 + static DEVICE_ATTR_RO(compat_id); 175 + 176 + static struct attribute *fpga_region_attrs[] = { 177 + &dev_attr_compat_id.attr, 178 + NULL, 179 + }; 180 + ATTRIBUTE_GROUPS(fpga_region); 181 + 161 182 /** 162 183 * fpga_region_create - alloc and init a struct fpga_region 163 184 * @dev: device parent ··· 279 258 if (IS_ERR(fpga_region_class)) 280 259 return PTR_ERR(fpga_region_class); 281 260 261 + fpga_region_class->dev_groups = fpga_region_groups; 282 262 fpga_region_class->dev_release = fpga_region_dev_release; 283 263 284 264 return 0;
+2
include/linux/fpga/fpga-region.h
··· 14 14 * @bridge_list: list of FPGA bridges specified in region 15 15 * @mgr: FPGA manager 16 16 * @info: FPGA image info 17 + * @compat_id: FPGA region id for compatibility check. 17 18 * @priv: private data 18 19 * @get_bridges: optional function to get bridges to a list 19 20 */ ··· 24 23 struct list_head bridge_list; 25 24 struct fpga_manager *mgr; 26 25 struct fpga_image_info *info; 26 + struct fpga_compat_id *compat_id; 27 27 void *priv; 28 28 int (*get_bridges)(struct fpga_region *region); 29 29 };