Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752253AbdGFSyH (ORCPT ); Thu, 6 Jul 2017 14:54:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:51516 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751816AbdGFSyF (ORCPT ); Thu, 6 Jul 2017 14:54:05 -0400 DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 084E822B53 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=atull@kernel.org MIME-Version: 1.0 In-Reply-To: <1499356977-4412-1-git-send-email-agust@denx.de> References: <1499356977-4412-1-git-send-email-agust@denx.de> From: Alan Tull Date: Thu, 6 Jul 2017 13:53:23 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] fpga manager: add notifier for manager register and unregister events To: Anatolij Gustschin Cc: Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5154 Lines: 141 On Thu, Jul 6, 2017 at 11:02 AM, Anatolij Gustschin 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 > --- > 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 > #include > #include > +#include > > 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 > #include > +#include > > #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