From patchwork Tue Feb 13 09:24:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wu, Hao" X-Patchwork-Id: 10215509 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 415DD6055C for ; Tue, 13 Feb 2018 09:41:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4189B28E52 for ; Tue, 13 Feb 2018 09:41:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3676B28E59; Tue, 13 Feb 2018 09:41:16 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B529828E52 for ; Tue, 13 Feb 2018 09:41:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934653AbeBMJfs (ORCPT ); Tue, 13 Feb 2018 04:35:48 -0500 Received: from mga03.intel.com ([134.134.136.65]:27128 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934508AbeBMJfq (ORCPT ); Tue, 13 Feb 2018 04:35:46 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Feb 2018 01:35:45 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,507,1511856000"; d="scan'208";a="26889571" Received: from hao-dev.bj.intel.com ([10.238.157.61]) by FMSMGA003.fm.intel.com with ESMTP; 13 Feb 2018 01:35:43 -0800 From: Wu Hao To: atull@kernel.org, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-api@vger.kernel.org, luwei.kang@intel.com, yi.z.zhang@intel.com, hao.wu@intel.com Subject: [PATCH v4 13/24] fpga: region: add compat_id support Date: Tue, 13 Feb 2018 17:24:42 +0800 Message-Id: <1518513893-4719-14-git-send-email-hao.wu@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518513893-4719-1-git-send-email-hao.wu@intel.com> References: <1518513893-4719-1-git-send-email-hao.wu@intel.com> Sender: linux-fpga-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fpga@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch introduces a compat_id member and sysfs interface for each fpga-region, e.g userspace applications could read the compat_id from the sysfs interface for compatibility checking before PR. Signed-off-by: Wu Hao --- Documentation/ABI/testing/sysfs-class-fpga-region | 5 +++++ drivers/fpga/fpga-region.c | 19 +++++++++++++++++++ include/linux/fpga/fpga-region.h | 13 +++++++++++++ 3 files changed, 37 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-class-fpga-region diff --git a/Documentation/ABI/testing/sysfs-class-fpga-region b/Documentation/ABI/testing/sysfs-class-fpga-region new file mode 100644 index 0000000..419d930 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-class-fpga-region @@ -0,0 +1,5 @@ +What: /sys/class/fpga_region//compat_id +Date: February 2018 +KernelVersion: 4.16 +Contact: Wu Hao +Description: FPGA region id for compatibility check. diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c index 660a91b..babec96 100644 --- a/drivers/fpga/fpga-region.c +++ b/drivers/fpga/fpga-region.c @@ -162,6 +162,24 @@ int fpga_region_program_fpga(struct fpga_region *region) } EXPORT_SYMBOL_GPL(fpga_region_program_fpga); +static ssize_t compat_id_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct fpga_region *region = to_fpga_region(dev); + + return sprintf(buf, "%016llx%016llx\n", + (unsigned long long)region->compat_id.id_h, + (unsigned long long)region->compat_id.id_l); +} + +static DEVICE_ATTR_RO(compat_id); + +static struct attribute *fpga_region_attrs[] = { + &dev_attr_compat_id.attr, + NULL, +}; +ATTRIBUTE_GROUPS(fpga_region); + int fpga_region_register(struct fpga_region *region) { struct device *dev = region->parent; @@ -226,6 +244,7 @@ static int __init fpga_region_init(void) if (IS_ERR(fpga_region_class)) return PTR_ERR(fpga_region_class); + fpga_region_class->dev_groups = fpga_region_groups; fpga_region_class->dev_release = fpga_region_dev_release; return 0; diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h index 423c87e..bf97dcc 100644 --- a/include/linux/fpga/fpga-region.h +++ b/include/linux/fpga/fpga-region.h @@ -6,6 +6,17 @@ #include /** + * struct fpga_region_compat_id - FPGA Region id for compatibility check + * + * @id_h: high 64bit of the compat_id + * @id_l: low 64bit of the compat_id + */ +struct fpga_region_compat_id { + u64 id_h; + u64 id_l; +}; + +/** * struct fpga_region - FPGA Region structure * @dev: FPGA Region device * @parent: parent device @@ -13,6 +24,7 @@ * @bridge_list: list of FPGA bridges specified in region * @mgr: FPGA manager * @info: FPGA image info + * @compat_id: FPGA region id for compatibility check. * @priv: private data * @get_bridges: optional function to get bridges to a list * @groups: optional attribute groups. @@ -24,6 +36,7 @@ struct fpga_region { struct list_head bridge_list; struct fpga_manager *mgr; struct fpga_image_info *info; + struct fpga_region_compat_id compat_id; void *priv; int (*get_bridges)(struct fpga_region *region); const struct attribute_group **groups;