linux-fpga.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: trix@redhat.com
To: mdf@kernel.org, corbet@lwn.net, hao.wu@intel.com
Cc: linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org,
	linux-kernel@vger.kernel.org, Tom Rix <trix@redhat.com>
Subject: [PATCH v2 2/4] fpga: region: introduce compat_id_show op
Date: Fri,  9 Jul 2021 06:42:27 -0700	[thread overview]
Message-ID: <20210709134229.2510349-4-trix@redhat.com> (raw)
In-Reply-To: <20210709134229.2510349-1-trix@redhat.com>

From: Tom Rix <trix@redhat.com>

The sysfs reported value for compat_id is implementation
dependent.  So add an optional op to fpga_region_ops to allow
an implementation to override the default.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/fpga/fpga-region.c       | 3 +++
 include/linux/fpga/fpga-region.h | 2 ++
 2 files changed, 5 insertions(+)

diff --git a/drivers/fpga/fpga-region.c b/drivers/fpga/fpga-region.c
index dfa35c2dc2720..864dd4f290e3b 100644
--- a/drivers/fpga/fpga-region.c
+++ b/drivers/fpga/fpga-region.c
@@ -169,6 +169,9 @@ static ssize_t compat_id_show(struct device *dev,
 {
 	struct fpga_region *region = to_fpga_region(dev);
 
+	if (region->rops && region->rops->compat_id_show)
+		return region->rops->compat_id_show(region, buf);
+
 	if (!region->compat_id)
 		return -ENOENT;
 
diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h
index d712344fd00a7..236d3819f1c13 100644
--- a/include/linux/fpga/fpga-region.h
+++ b/include/linux/fpga/fpga-region.h
@@ -12,6 +12,7 @@ struct fpga_region;
 /**
  * struct fpga_region_ops - ops for low level fpga region drivers
  * @get_bridges: optional function to get bridges to a list
+ * @compat_id_show: optional function emit to sysfs a compatible id
  *
  * fpga_region_ops are the low level functions implemented by a specific
  * fpga region driver.  The optional ones are tested for NULL before being
@@ -19,6 +20,7 @@ struct fpga_region;
  */
 struct fpga_region_ops {
 	int (*get_bridges)(struct fpga_region *region);
+	ssize_t (*compat_id_show)(struct fpga_region *region, char *buf);
 };
 
 /**
-- 
2.26.3


  parent reply	other threads:[~2021-07-09 13:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-09 13:42 [PATCH v2 0/4] fpga: fpga-mgr: move compat_id from fpga_mgr to dfl trix
2021-07-09 13:42 ` [PATCH v2 1/4] fpga: region: introduce fpga_region_ops trix
2021-07-09 13:42 ` trix [this message]
2021-07-09 13:42 ` [PATCH v2 3/4] fpga: dfl: implement the compat_id_show region op trix
2021-07-09 21:58   ` kernel test robot
2021-07-12  1:27   ` Wu, Hao
2021-07-09 13:42 ` [PATCH v2 4/4] fpga: remove compat_id from fpga_manager and fpga_region trix
2021-07-12  1:40   ` Wu, Hao
2021-07-12 15:53     ` Tom Rix
2021-07-21  4:48       ` Wu, Hao
2021-07-21 14:56         ` Tom Rix
2021-07-22  0:18           ` Wu, Hao
2021-07-22 13:58             ` Tom Rix
2021-07-20 19:47 ` [PATCH v2 0/4] fpga: fpga-mgr: move compat_id from fpga_mgr to dfl Tom Rix

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210709134229.2510349-4-trix@redhat.com \
    --to=trix@redhat.com \
    --cc=corbet@lwn.net \
    --cc=hao.wu@intel.com \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-fpga@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mdf@kernel.org \
    --subject='Re: [PATCH v2 2/4] fpga: region: introduce compat_id_show op' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).