[PATCH 0/4] fpga: Add dummy definitions of API functions

Ian Abbott posted 4 patches 3 months ago
There is a newer version of this series
include/linux/fpga/altera-pr-ip-core.h |  8 ++-
include/linux/fpga/fpga-bridge.h       | 75 ++++++++++++++++++++++++++-
include/linux/fpga/fpga-mgr.h          | 95 +++++++++++++++++++++++++++++++---
include/linux/fpga/fpga-region.h       | 44 ++++++++++++++--
4 files changed, 207 insertions(+), 15 deletions(-)
[PATCH 0/4] fpga: Add dummy definitions of API functions
Posted by Ian Abbott 3 months ago
Add dummy definitions of the FPGA API functions for build testing

1) fpga: altera-pr-ip: Add dummy definitions of API functions
2) fpga: bridge: Add dummy definitions of API functions
3) fpga: manager: Add dummy definitions of API functions
4) fpga: region: Add dummy definitions of API functions

 include/linux/fpga/altera-pr-ip-core.h |  8 ++-
 include/linux/fpga/fpga-bridge.h       | 75 ++++++++++++++++++++++++++-
 include/linux/fpga/fpga-mgr.h          | 95 +++++++++++++++++++++++++++++++---
 include/linux/fpga/fpga-region.h       | 44 ++++++++++++++--
 4 files changed, 207 insertions(+), 15 deletions(-)
[PATCH v2 0/4] fpga: Add dummy definitions of API functions
Posted by Ian Abbott 3 months ago
Add dummy definitions of the FPGA API functions for build testing.

v2: (1) Add a missing #endif to altera-pr-ip-core.h
    (2) Change conditional compilation tests to use #if
        IS_ENABLED(CONFIG_xxx) instead of #ifdef CONFIG_xxx to avoid
        compilation errors when the options are configured as modules.

1) fpga: altera-pr-ip: Add dummy definitions of API functions
2) fpga: bridge: Add dummy definitions of API functions
3) fpga: manager: Add dummy definitions of API functions
4) fpga: region: Add dummy definitions of API functions

 include/linux/fpga/altera-pr-ip-core.h |  8 +++
 include/linux/fpga/fpga-bridge.h       | 75 ++++++++++++++++++++++++++-
 include/linux/fpga/fpga-mgr.h          | 95 +++++++++++++++++++++++++++++++---
 include/linux/fpga/fpga-region.h       | 44 ++++++++++++++--
 4 files changed, 208 insertions(+), 14 deletions(-)
[PATCH v2 1/4] fpga: altera-pr-ip: Add dummy definitions of API functions
Posted by Ian Abbott 3 months ago
Add a dummy definition of alt_pr_register() for build testing.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
v2: (1) Add missing #endif.
    (2) Correct conditional compilation test for ALTERA_PR_IP_CORE
        tristate configuration.
---
 include/linux/fpga/altera-pr-ip-core.h | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/include/linux/fpga/altera-pr-ip-core.h b/include/linux/fpga/altera-pr-ip-core.h
index a6b4c07858cc..f91b4cf918fb 100644
--- a/include/linux/fpga/altera-pr-ip-core.h
+++ b/include/linux/fpga/altera-pr-ip-core.h
@@ -11,7 +11,15 @@
 #ifndef _ALT_PR_IP_CORE_H
 #define _ALT_PR_IP_CORE_H
 #include <linux/io.h>
+#include <asm/errno.h>
 
+#if IS_ENABLED(CONFIG_ALTERA_PR_IP_CORE)
 int alt_pr_register(struct device *dev, void __iomem *reg_base);
+#else
+static inline int alt_pr_register(struct device *dev, void __iomem *reg_base)
+{
+	return -EOPNOTSUPP;
+}
+#endif
 
 #endif /* _ALT_PR_IP_CORE_H */
-- 
2.51.0
[PATCH v2 2/4] fpga: bridge: Add dummy definitions of API functions
Posted by Ian Abbott 3 months ago
Add dummy versions of the FPGA bridge API functions for build testing.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
v2: Correct conditional compilation test for FPGA_BRIDGE tristate
    configuration.
---
 include/linux/fpga/fpga-bridge.h | 75 +++++++++++++++++++++++++++++++-
 1 file changed, 73 insertions(+), 2 deletions(-)

diff --git a/include/linux/fpga/fpga-bridge.h b/include/linux/fpga/fpga-bridge.h
index 94c4edd047e5..82494cc325f3 100644
--- a/include/linux/fpga/fpga-bridge.h
+++ b/include/linux/fpga/fpga-bridge.h
@@ -5,6 +5,7 @@
 
 #include <linux/device.h>
 #include <linux/fpga/fpga-mgr.h>
+#include <linux/err.h>
 
 struct fpga_bridge;
 
@@ -63,6 +64,10 @@ struct fpga_bridge {
 
 #define to_fpga_bridge(d) container_of(d, struct fpga_bridge, dev)
 
+#define fpga_bridge_register(parent, name, br_ops, priv) \
+	__fpga_bridge_register(parent, name, br_ops, priv, THIS_MODULE)
+
+#if IS_ENABLED(CONFIG_FPGA_BRIDGE)
 struct fpga_bridge *of_fpga_bridge_get(struct device_node *node,
 				       struct fpga_image_info *info);
 struct fpga_bridge *fpga_bridge_get(struct device *dev,
@@ -81,12 +86,78 @@ int of_fpga_bridge_get_to_list(struct device_node *np,
 			       struct fpga_image_info *info,
 			       struct list_head *bridge_list);
 
-#define fpga_bridge_register(parent, name, br_ops, priv) \
-	__fpga_bridge_register(parent, name, br_ops, priv, THIS_MODULE)
 struct fpga_bridge *
 __fpga_bridge_register(struct device *parent, const char *name,
 		       const struct fpga_bridge_ops *br_ops, void *priv,
 		       struct module *owner);
 void fpga_bridge_unregister(struct fpga_bridge *br);
 
+#else
+static inline struct fpga_bridge *
+of_fpga_bridge_get(struct device_node *node, struct fpga_image_info *info)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct fpga_bridge *
+fpga_bridge_get(struct device *dev, struct fpga_image_info *info)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline void fpga_bridge_put(struct fpga_bridge *bridge)
+{
+}
+
+static inline int fpga_bridge_enable(struct fpga_bridge *bridge)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int fpga_bridge_disable(struct fpga_bridge *bridge)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int fpga_bridges_enable(struct list_head *bridge_list)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int fpga_bridges_disable(struct list_head *bridge_list)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline void fpga_bridges_put(struct list_head *bridge_list)
+{
+}
+
+static inline int fpga_bridge_get_to_list(struct device *dev,
+					  struct fpga_image_info *info,
+					  struct list_head *bridge_list)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int of_fpga_bridge_get_to_list(struct device_node *np,
+					     struct fpga_image_info *info,
+					     struct list_head *bridge_list)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline struct fpga_bridge *
+__fpga_bridge_register(struct device *parent, const char *name,
+		       const struct fpga_bridge_ops *br_ops, void *priv,
+		       struct module *owner)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline void fpga_bridge_unregister(struct fpga_bridge *br)
+{
+}
+#endif
+
 #endif /* _LINUX_FPGA_BRIDGE_H */
-- 
2.51.0
[PATCH v2 3/4] fpga: manager: Add dummy definitions of API functions
Posted by Ian Abbott 3 months ago
Add dummy versions of the FPGA manager API functions for build testing.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
v2: Correct conditional compilation test for FPGA_MGR tristate
    configuration.
---
 include/linux/fpga/fpga-mgr.h | 95 ++++++++++++++++++++++++++++++++---
 1 file changed, 87 insertions(+), 8 deletions(-)

diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index 0d4fe068f3d8..38a139edc29c 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -10,6 +10,7 @@
 
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/err.h>
 
 struct fpga_manager;
 struct sg_table;
@@ -217,6 +218,19 @@ struct fpga_manager {
 
 #define to_fpga_manager(d) container_of(d, struct fpga_manager, dev)
 
+#define fpga_mgr_register_full(parent, info) \
+	__fpga_mgr_register_full(parent, info, THIS_MODULE)
+
+#define fpga_mgr_register(parent, name, mops, priv) \
+	__fpga_mgr_register(parent, name, mops, priv, THIS_MODULE)
+
+#define devm_fpga_mgr_register_full(parent, info) \
+	__devm_fpga_mgr_register_full(parent, info, THIS_MODULE)
+
+#define devm_fpga_mgr_register(parent, name, mops, priv) \
+	__devm_fpga_mgr_register(parent, name, mops, priv, THIS_MODULE)
+
+#if IS_ENABLED(CONFIG_FPGA)
 struct fpga_image_info *fpga_image_info_alloc(struct device *dev);
 
 void fpga_image_info_free(struct fpga_image_info *info);
@@ -232,30 +246,95 @@ struct fpga_manager *fpga_mgr_get(struct device *dev);
 
 void fpga_mgr_put(struct fpga_manager *mgr);
 
-#define fpga_mgr_register_full(parent, info) \
-	__fpga_mgr_register_full(parent, info, THIS_MODULE)
 struct fpga_manager *
 __fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info,
 			 struct module *owner);
 
-#define fpga_mgr_register(parent, name, mops, priv) \
-	__fpga_mgr_register(parent, name, mops, priv, THIS_MODULE)
 struct fpga_manager *
 __fpga_mgr_register(struct device *parent, const char *name,
 		    const struct fpga_manager_ops *mops, void *priv, struct module *owner);
 
 void fpga_mgr_unregister(struct fpga_manager *mgr);
 
-#define devm_fpga_mgr_register_full(parent, info) \
-	__devm_fpga_mgr_register_full(parent, info, THIS_MODULE)
 struct fpga_manager *
 __devm_fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info,
 			      struct module *owner);
-#define devm_fpga_mgr_register(parent, name, mops, priv) \
-	__devm_fpga_mgr_register(parent, name, mops, priv, THIS_MODULE)
 struct fpga_manager *
 __devm_fpga_mgr_register(struct device *parent, const char *name,
 			 const struct fpga_manager_ops *mops, void *priv,
 			 struct module *owner);
 
+#else
+static inline struct fpga_image_info *fpga_image_info_alloc(struct device *dev)
+{
+	return NULL;
+}
+
+static inline void fpga_image_info_free(struct fpga_image_info *info)
+{
+}
+
+static inline int fpga_mgr_load(struct fpga_manager *mgr,
+				struct fpga_image_info *info)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int fpga_mgr_lock(struct fpga_manager *mgr)
+{
+	return 0;
+}
+
+static inline void fpga_mgr_unlock(struct fpga_manager *mgr)
+{
+}
+
+static inline struct fpga_manager *of_fpga_mgr_get(struct device_node *node)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct fpga_manager *fpga_mgr_get(struct device *dev)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline void fpga_mgr_put(struct fpga_manager *mgr)
+{
+}
+
+static inline struct fpga_manager *
+__fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info,
+			 struct module *owner)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct fpga_manager *
+__fpga_mgr_register(struct device *parent, const char *name,
+		    const struct fpga_manager_ops *mops, void *priv, struct module *owner)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline void fpga_mgr_unregister(struct fpga_manager *mgr)
+{
+}
+
+static inline struct fpga_manager *
+__devm_fpga_mgr_register_full(struct device *parent, const struct fpga_manager_info *info,
+			      struct module *owner)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct fpga_manager *
+__devm_fpga_mgr_register(struct device *parent, const char *name,
+			 const struct fpga_manager_ops *mops, void *priv,
+			 struct module *owner)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+#endif
+
 #endif /*_LINUX_FPGA_MGR_H */
-- 
2.51.0
[PATCH v2 4/4] fpga: region: Add dummy definitions of API functions
Posted by Ian Abbott 3 months ago
Add dummy definitions of the FPGA region API functions for build
testing.

Signed-off-by: Ian Abbott <abbotti@mev.co.uk>
---
v2: Correct conditional compilation test for FPGA_REGION tristate
    configuration.
---
 include/linux/fpga/fpga-region.h | 44 +++++++++++++++++++++++++++++---
 1 file changed, 40 insertions(+), 4 deletions(-)

diff --git a/include/linux/fpga/fpga-region.h b/include/linux/fpga/fpga-region.h
index 5fbc05fe70a6..11263b33f0dc 100644
--- a/include/linux/fpga/fpga-region.h
+++ b/include/linux/fpga/fpga-region.h
@@ -6,6 +6,7 @@
 #include <linux/device.h>
 #include <linux/fpga/fpga-mgr.h>
 #include <linux/fpga/fpga-bridge.h>
+#include <linux/err.h>
 
 struct fpga_region;
 
@@ -54,23 +55,58 @@ struct fpga_region {
 
 #define to_fpga_region(d) container_of(d, struct fpga_region, dev)
 
+#define fpga_region_register_full(parent, info) \
+	__fpga_region_register_full(parent, info, THIS_MODULE)
+
+#define fpga_region_register(parent, mgr, get_bridges) \
+	__fpga_region_register(parent, mgr, get_bridges, THIS_MODULE)
+
+#if IS_ENABLED(CONFIG_FPGA_REGION)
 struct fpga_region *
 fpga_region_class_find(struct device *start, const void *data,
 		       int (*match)(struct device *, const void *));
 
 int fpga_region_program_fpga(struct fpga_region *region);
 
-#define fpga_region_register_full(parent, info) \
-	__fpga_region_register_full(parent, info, THIS_MODULE)
 struct fpga_region *
 __fpga_region_register_full(struct device *parent, const struct fpga_region_info *info,
 			    struct module *owner);
 
-#define fpga_region_register(parent, mgr, get_bridges) \
-	__fpga_region_register(parent, mgr, get_bridges, THIS_MODULE)
 struct fpga_region *
 __fpga_region_register(struct device *parent, struct fpga_manager *mgr,
 		       int (*get_bridges)(struct fpga_region *), struct module *owner);
 void fpga_region_unregister(struct fpga_region *region);
 
+#else
+static inline struct fpga_region *
+fpga_region_class_find(struct device *start, const void *data,
+		       int (*match)(struct device *, const void *))
+{
+	return NULL;
+}
+
+static inline int fpga_region_program_fpga(struct fpga_region *region)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline struct fpga_region *
+__fpga_region_register_full(struct device *parent, const struct fpga_region_info *info,
+			    struct module *owner)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline struct fpga_region *
+__fpga_region_register(struct device *parent, struct fpga_manager *mgr,
+		       int (*get_bridges)(struct fpga_region *), struct module *owner)
+{
+	return ERR_PTR(-EOPNOTSUPP);
+}
+
+static inline void fpga_region_unregister(struct fpga_region *region)
+{
+}
+#endif
+
 #endif /* _FPGA_REGION_H */
-- 
2.51.0
Re: [PATCH 0/4] fpga: Add dummy definitions of API functions
Posted by Xu Yilun 3 months ago
On Tue, Nov 04, 2025 at 03:27:01PM +0000, Ian Abbott wrote:
> Add dummy definitions of the FPGA API functions for build testing
> 
> 1) fpga: altera-pr-ip: Add dummy definitions of API functions
> 2) fpga: bridge: Add dummy definitions of API functions
> 3) fpga: manager: Add dummy definitions of API functions
> 4) fpga: region: Add dummy definitions of API functions

Sorry I don't get the idea. Why should someone use FPGA APIs without
selecting CONIG_FPGA_XXX? Better make the changes along with the use
case patches.

Thanks,
Yilun

> 
>  include/linux/fpga/altera-pr-ip-core.h |  8 ++-
>  include/linux/fpga/fpga-bridge.h       | 75 ++++++++++++++++++++++++++-
>  include/linux/fpga/fpga-mgr.h          | 95 +++++++++++++++++++++++++++++++---
>  include/linux/fpga/fpga-region.h       | 44 ++++++++++++++--
>  4 files changed, 207 insertions(+), 15 deletions(-)
>
Re: [PATCH 0/4] fpga: Add dummy definitions of API functions
Posted by Ian Abbott 3 months ago
On 2025-11-05 01:47, Xu Yilun wrote:
> On Tue, Nov 04, 2025 at 03:27:01PM +0000, Ian Abbott wrote:
>> Add dummy definitions of the FPGA API functions for build testing
>>
>> 1) fpga: altera-pr-ip: Add dummy definitions of API functions
>> 2) fpga: bridge: Add dummy definitions of API functions
>> 3) fpga: manager: Add dummy definitions of API functions
>> 4) fpga: region: Add dummy definitions of API functions
> 
> Sorry I don't get the idea. Why should someone use FPGA APIs without
> selecting CONIG_FPGA_XXX? Better make the changes along with the use
> case patches.

Projects using FPGAs often have custom devices with custom, out-of-tree 
drivers, so it's quite useful to be able to build test those drivers 
against later kernel versions on the host to keep up with kernel API 
drift, prior to possible later adoption of the kernel version on the target.

> Thanks,
> Yilun
> 
>>
>>   include/linux/fpga/altera-pr-ip-core.h |  8 ++-
>>   include/linux/fpga/fpga-bridge.h       | 75 ++++++++++++++++++++++++++-
>>   include/linux/fpga/fpga-mgr.h          | 95 +++++++++++++++++++++++++++++++---
>>   include/linux/fpga/fpga-region.h       | 44 ++++++++++++++--
>>   4 files changed, 207 insertions(+), 15 deletions(-)
However, I messed up the patches, because I only built them without the 
FPGA configure options defined.  I plan to submit a v2 patch series 
unless it is deemed a complete waste of effort by the maintainers.

Cheers,
Ian
-- 
-=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company  )=-
-=( registered in England & Wales.  Regd. number: 02862268.  )=-
-=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
-=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
Re: [PATCH 0/4] fpga: Add dummy definitions of API functions
Posted by Xu Yilun 3 months ago
On Wed, Nov 05, 2025 at 10:37:39AM +0000, Ian Abbott wrote:
> On 2025-11-05 01:47, Xu Yilun wrote:
> > On Tue, Nov 04, 2025 at 03:27:01PM +0000, Ian Abbott wrote:
> > > Add dummy definitions of the FPGA API functions for build testing
> > > 
> > > 1) fpga: altera-pr-ip: Add dummy definitions of API functions
> > > 2) fpga: bridge: Add dummy definitions of API functions
> > > 3) fpga: manager: Add dummy definitions of API functions
> > > 4) fpga: region: Add dummy definitions of API functions
> > 
> > Sorry I don't get the idea. Why should someone use FPGA APIs without
> > selecting CONIG_FPGA_XXX? Better make the changes along with the use
> > case patches.
> 
> Projects using FPGAs often have custom devices with custom, out-of-tree
> drivers, so it's quite useful to be able to build test those drivers against
> later kernel versions on the host to keep up with kernel API drift, prior to

But why don't you select the FPGA options on your "later kernel"? I
don't see much benifit for not doing so. Finally you still need
runtime test for new kernel adoption which requires selecting these
FPGA options.

And the problem for these stubs is, real users lose the chance to find
config error at earlier stage.

> possible later adoption of the kernel version on the target.
> 
> > Thanks,
> > Yilun
> > 
> > > 
> > >   include/linux/fpga/altera-pr-ip-core.h |  8 ++-
> > >   include/linux/fpga/fpga-bridge.h       | 75 ++++++++++++++++++++++++++-
> > >   include/linux/fpga/fpga-mgr.h          | 95 +++++++++++++++++++++++++++++++---
> > >   include/linux/fpga/fpga-region.h       | 44 ++++++++++++++--
> > >   4 files changed, 207 insertions(+), 15 deletions(-)
> However, I messed up the patches, because I only built them without the FPGA
> configure options defined.  I plan to submit a v2 patch series unless it is
> deemed a complete waste of effort by the maintainers.

Sorry, for now it still seems unnecessary to me.

Thanks,
Yilun

> 
> Cheers,
> Ian
> -- 
> -=( Ian Abbott <abbotti@mev.co.uk> || MEV Ltd. is a company  )=-
> -=( registered in England & Wales.  Regd. number: 02862268.  )=-
> -=( Regd. addr.: S11 & 12 Building 67, Europa Business Park, )=-
> -=( Bird Hall Lane, STOCKPORT, SK3 0XA, UK. || www.mev.co.uk )=-
>