Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1682546 > unrolled thread

[PATCH] fpga manager: add notifier for manager register and unregister events

Started byAnatolij Gustschin <agust@denx.de>
First post2017-07-06 18:10 +0200
Last post2017-07-07 00:40 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] fpga manager: add notifier for manager register and unregister events Anatolij Gustschin <agust@denx.de> - 2017-07-06 18:10 +0200
    Re: [PATCH] fpga manager: add notifier for manager register and  unregister events Alan Tull <atull@kernel.org> - 2017-07-06 21:00 +0200
      Re: [PATCH] fpga manager: add notifier for manager register and  unregister events Anatolij Gustschin <agust@denx.de> - 2017-07-07 00:40 +0200

#1682546 — [PATCH] fpga manager: add notifier for manager register and unregister events

FromAnatolij Gustschin <agust@denx.de>
Date2017-07-06 18:10 +0200
Subject[PATCH] fpga manager: add notifier for manager register and unregister events
Message-ID<u0hvQ-7HB-23@gated-at.bofh.it>
Add API functions for registering and removing a notifier for FPGA
manager register/unregister events. Notify when a new FPGA manager
has been registered or when an existing manager is being removed.
This will help configuration interface drivers to get the notion
of low-level FPGA managers popping up or disappearing, when using
hotpluggable FPGA configuration devices (e.g. via USB-SPI adapters).

Signed-off-by: Anatolij Gustschin <agust@denx.de>
---
 Documentation/fpga/fpga-mgr.txt |  8 ++++++++
 drivers/fpga/fpga-mgr.c         | 34 ++++++++++++++++++++++++++++++++++
 include/linux/fpga/fpga-mgr.h   | 13 +++++++++++++
 3 files changed, 55 insertions(+)

diff --git a/Documentation/fpga/fpga-mgr.txt b/Documentation/fpga/fpga-mgr.txt
index 78f197f..e81d566 100644
--- a/Documentation/fpga/fpga-mgr.txt
+++ b/Documentation/fpga/fpga-mgr.txt
@@ -73,6 +73,14 @@ Use of these two functions is described below in "How To Support a new FPGA
 device."
 
 
+To register or unregister the notifier callback for signalling
+about the low level FPGA-Managers being added or removed:
+----------------------------------------------------------
+
+	void fpga_mgr_register_mgr_notifier(struct notifier_block *nb);
+	void fpga_mgr_unregister_mgr_notifier(struct notifier_block *nb);
+
+
 How to write an image buffer to a supported FPGA
 ================================================
 /* Include to get the API */
diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
index 188ffef..7362bb4 100644
--- a/drivers/fpga/fpga-mgr.c
+++ b/drivers/fpga/fpga-mgr.c
@@ -27,10 +27,39 @@
 #include <linux/slab.h>
 #include <linux/scatterlist.h>
 #include <linux/highmem.h>
+#include <linux/notifier.h>
 
 static DEFINE_IDA(fpga_mgr_ida);
 static struct class *fpga_mgr_class;
 
+static BLOCKING_NOTIFIER_HEAD(fpga_mgr_notifier_list);
+
+/**
+ * fpga_mgr_register_mgr_notifier() - register fpga manager notifier callback
+ * @nb: pointer to the notifier block for the callback events.
+ *
+ * Add a notifier callback for FPGA manager changes. These changes are
+ * either FPGA manager being added or removed.
+ */
+void fpga_mgr_register_mgr_notifier(struct notifier_block *nb)
+{
+	blocking_notifier_chain_register(&fpga_mgr_notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(fpga_mgr_register_mgr_notifier);
+
+/**
+ * fpga_mgr_unregister_mgr_notifier() - unregister a notifier callback
+ * @nb: pointer to the notifier block for the callback events.
+ *
+ * Remove a notifier callback. fpga_mgr_register_mgr_notifier() must have
+ * been previously called for this function to work properly.
+ */
+void fpga_mgr_unregister_mgr_notifier(struct notifier_block *nb)
+{
+	blocking_notifier_chain_unregister(&fpga_mgr_notifier_list, nb);
+}
+EXPORT_SYMBOL_GPL(fpga_mgr_unregister_mgr_notifier);
+
 /*
  * Call the low level driver's write_init function.  This will do the
  * device-specific things to get the FPGA into the state where it is ready to
@@ -518,6 +547,8 @@ int fpga_mgr_register(struct device *dev, const char *name,
 
 	dev_info(&mgr->dev, "%s registered\n", mgr->name);
 
+	blocking_notifier_call_chain(&fpga_mgr_notifier_list,
+				     FPGA_MGR_ADD, mgr);
 	return 0;
 
 error_device:
@@ -539,6 +570,9 @@ void fpga_mgr_unregister(struct device *dev)
 
 	dev_info(&mgr->dev, "%s %s\n", __func__, mgr->name);
 
+	blocking_notifier_call_chain(&fpga_mgr_notifier_list,
+				     FPGA_MGR_REMOVE, mgr);
+
 	/*
 	 * If the low level driver provides a method for putting fpga into
 	 * a desired state upon unregister, do it.
diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
index b4ac24c..7ed4f68 100644
--- a/include/linux/fpga/fpga-mgr.h
+++ b/include/linux/fpga/fpga-mgr.h
@@ -17,6 +17,7 @@
  */
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
+#include <linux/notifier.h>
 
 #ifndef _LINUX_FPGA_MGR_H
 #define _LINUX_FPGA_MGR_H
@@ -154,4 +155,16 @@ int fpga_mgr_register(struct device *dev, const char *name,
 
 void fpga_mgr_unregister(struct device *dev);
 
+/*
+ * FPGA Manager register notifier events
+ * FPGA_MGR_ADD: a new fpga manager has been registered
+ * FPGA_MGR_REMOVE: a registered fpga manager is being removed
+ */
+#define FPGA_MGR_ADD	1
+#define FPGA_MGR_REMOVE	2
+
+void fpga_mgr_register_mgr_notifier(struct notifier_block *nb);
+
+void fpga_mgr_unregister_mgr_notifier(struct notifier_block *nb);
+
 #endif /*_LINUX_FPGA_MGR_H */
-- 
2.7.4

[toc] | [next] | [standalone]


#1682657 — Re: [PATCH] fpga manager: add notifier for manager register and unregister events

FromAlan Tull <atull@kernel.org>
Date2017-07-06 21:00 +0200
SubjectRe: [PATCH] fpga manager: add notifier for manager register and unregister events
Message-ID<u0kal-RF-17@gated-at.bofh.it>
In reply to#1682546
On Thu, Jul 6, 2017 at 11:02 AM, Anatolij Gustschin <agust@denx.de> wrote:
> Add API functions for registering and removing a notifier for FPGA
> manager register/unregister events. Notify when a new FPGA manager
> has been registered or when an existing manager is being removed.
> This will help configuration interface drivers to get the notion
> of low-level FPGA managers popping up or disappearing, when using
> hotpluggable FPGA configuration devices (e.g. via USB-SPI adapters).
>

Hi Anatolij,

This is interesting and looks pretty straightforward.  Do you have any
code that uses it?

Alan

> Signed-off-by: Anatolij Gustschin <agust@denx.de>
> ---
>  Documentation/fpga/fpga-mgr.txt |  8 ++++++++
>  drivers/fpga/fpga-mgr.c         | 34 ++++++++++++++++++++++++++++++++++
>  include/linux/fpga/fpga-mgr.h   | 13 +++++++++++++
>  3 files changed, 55 insertions(+)
>
> diff --git a/Documentation/fpga/fpga-mgr.txt b/Documentation/fpga/fpga-mgr.txt
> index 78f197f..e81d566 100644
> --- a/Documentation/fpga/fpga-mgr.txt
> +++ b/Documentation/fpga/fpga-mgr.txt
> @@ -73,6 +73,14 @@ Use of these two functions is described below in "How To Support a new FPGA
>  device."
>
>
> +To register or unregister the notifier callback for signalling
> +about the low level FPGA-Managers being added or removed:
> +----------------------------------------------------------
> +
> +       void fpga_mgr_register_mgr_notifier(struct notifier_block *nb);
> +       void fpga_mgr_unregister_mgr_notifier(struct notifier_block *nb);
> +
> +
>  How to write an image buffer to a supported FPGA
>  ================================================
>  /* Include to get the API */
> diff --git a/drivers/fpga/fpga-mgr.c b/drivers/fpga/fpga-mgr.c
> index 188ffef..7362bb4 100644
> --- a/drivers/fpga/fpga-mgr.c
> +++ b/drivers/fpga/fpga-mgr.c
> @@ -27,10 +27,39 @@
>  #include <linux/slab.h>
>  #include <linux/scatterlist.h>
>  #include <linux/highmem.h>
> +#include <linux/notifier.h>
>
>  static DEFINE_IDA(fpga_mgr_ida);
>  static struct class *fpga_mgr_class;
>
> +static BLOCKING_NOTIFIER_HEAD(fpga_mgr_notifier_list);
> +
> +/**
> + * fpga_mgr_register_mgr_notifier() - register fpga manager notifier callback
> + * @nb: pointer to the notifier block for the callback events.
> + *
> + * Add a notifier callback for FPGA manager changes. These changes are
> + * either FPGA manager being added or removed.
> + */
> +void fpga_mgr_register_mgr_notifier(struct notifier_block *nb)
> +{
> +       blocking_notifier_chain_register(&fpga_mgr_notifier_list, nb);
> +}
> +EXPORT_SYMBOL_GPL(fpga_mgr_register_mgr_notifier);
> +
> +/**
> + * fpga_mgr_unregister_mgr_notifier() - unregister a notifier callback
> + * @nb: pointer to the notifier block for the callback events.
> + *
> + * Remove a notifier callback. fpga_mgr_register_mgr_notifier() must have
> + * been previously called for this function to work properly.
> + */
> +void fpga_mgr_unregister_mgr_notifier(struct notifier_block *nb)
> +{
> +       blocking_notifier_chain_unregister(&fpga_mgr_notifier_list, nb);
> +}
> +EXPORT_SYMBOL_GPL(fpga_mgr_unregister_mgr_notifier);
> +
>  /*
>   * Call the low level driver's write_init function.  This will do the
>   * device-specific things to get the FPGA into the state where it is ready to
> @@ -518,6 +547,8 @@ int fpga_mgr_register(struct device *dev, const char *name,
>
>         dev_info(&mgr->dev, "%s registered\n", mgr->name);
>
> +       blocking_notifier_call_chain(&fpga_mgr_notifier_list,
> +                                    FPGA_MGR_ADD, mgr);
>         return 0;
>
>  error_device:
> @@ -539,6 +570,9 @@ void fpga_mgr_unregister(struct device *dev)
>
>         dev_info(&mgr->dev, "%s %s\n", __func__, mgr->name);
>
> +       blocking_notifier_call_chain(&fpga_mgr_notifier_list,
> +                                    FPGA_MGR_REMOVE, mgr);
> +
>         /*
>          * If the low level driver provides a method for putting fpga into
>          * a desired state upon unregister, do it.
> diff --git a/include/linux/fpga/fpga-mgr.h b/include/linux/fpga/fpga-mgr.h
> index b4ac24c..7ed4f68 100644
> --- a/include/linux/fpga/fpga-mgr.h
> +++ b/include/linux/fpga/fpga-mgr.h
> @@ -17,6 +17,7 @@
>   */
>  #include <linux/mutex.h>
>  #include <linux/platform_device.h>
> +#include <linux/notifier.h>
>
>  #ifndef _LINUX_FPGA_MGR_H
>  #define _LINUX_FPGA_MGR_H
> @@ -154,4 +155,16 @@ int fpga_mgr_register(struct device *dev, const char *name,
>
>  void fpga_mgr_unregister(struct device *dev);
>
> +/*
> + * FPGA Manager register notifier events
> + * FPGA_MGR_ADD: a new fpga manager has been registered
> + * FPGA_MGR_REMOVE: a registered fpga manager is being removed
> + */
> +#define FPGA_MGR_ADD   1
> +#define FPGA_MGR_REMOVE        2
> +
> +void fpga_mgr_register_mgr_notifier(struct notifier_block *nb);
> +
> +void fpga_mgr_unregister_mgr_notifier(struct notifier_block *nb);
> +
>  #endif /*_LINUX_FPGA_MGR_H */
> --
> 2.7.4
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-fpga" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

[toc] | [prev] | [next] | [standalone]


#1682775 — Re: [PATCH] fpga manager: add notifier for manager register and unregister events

FromAnatolij Gustschin <agust@denx.de>
Date2017-07-07 00:40 +0200
SubjectRe: [PATCH] fpga manager: add notifier for manager register and unregister events
Message-ID<u0nBf-3lx-5@gated-at.bofh.it>
In reply to#1682657
Hi Alan,

On Thu, 6 Jul 2017 13:53:23 -0500
Alan Tull atull@kernel.org wrote:
...
>This is interesting and looks pretty straightforward.  Do you have any
>code that uses it?

I've send a patch series for FPP manager, it will add the FPGA manager
when an FTDI based configuration device is connected via USB and the
manager will disappear when this device is unplugged. I have code
with configuration interface for this manager, but it is something
special and not suitable for mainline, I think. It creates the
configuration interface when a new manager is detected and removes
this interface when the device is detached.

Thanks,
Anatolij

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web