[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 01/21] notifier: Add blocking_notifier_call_chain_is_empty()
 
- To: Thierry Reding <thierry.reding@xxxxxxxxx>,	Jonathan Hunter <jonathanh@xxxxxxxxxx>,	Russell King <linux@xxxxxxxxxxxxxxx>,	Catalin Marinas <catalin.marinas@xxxxxxx>,	Will Deacon <will@xxxxxxxxxx>,	Guo Ren <guoren@xxxxxxxxxx>,	Geert Uytterhoeven <geert@xxxxxxxxxxxxxx>,	Greg Ungerer <gerg@xxxxxxxxxxxxxx>,	Joshua Thompson <funaho@xxxxxxxxx>,	Thomas Bogendoerfer <tsbogend@xxxxxxxxxxxxxxxx>,	Sebastian Reichel <sre@xxxxxxxxxx>,	Linus Walleij <linus.walleij@xxxxxxxxxx>,	Philipp Zabel <p.zabel@xxxxxxxxxxxxxx>,	Greentime Hu <green.hu@xxxxxxxxx>,	Vincent Chen <deanbo422@xxxxxxxxx>,	"James E.J. Bottomley" <James.Bottomley@xxxxxxxxxxxxxxxxxxxxx>,	Helge Deller <deller@xxxxxx>,	Michael Ellerman <mpe@xxxxxxxxxxxxxx>,	Benjamin Herrenschmidt <benh@xxxxxxxxxxxxxxxxxxx>,	Paul Mackerras <paulus@xxxxxxxxx>,	Paul Walmsley <paul.walmsley@xxxxxxxxxx>,	Palmer Dabbelt <palmer@xxxxxxxxxxx>,	Albert Ou <aou@xxxxxxxxxxxxxxxxx>,	Yoshinori Sato <ysato@xxxxxxxxxxxxxxxxxxxx>,	Rich Felker <dalias@xxxxxxxx>,	Thomas Gleixner <tglx@xxxxxxxxxxxxx>,	Ingo Molnar <mingo@xxxxxxxxxx>,	Borislav Petkov <bp@xxxxxxxxx>,	Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>,	x86@xxxxxxxxxx,	"H. Peter Anvin" <hpa@xxxxxxxxx>,	Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>,	Juergen Gross <jgross@xxxxxxxx>,	Stefano Stabellini <sstabellini@xxxxxxxxxx>,	"Rafael J. Wysocki" <rafael@xxxxxxxxxx>,	Len Brown <lenb@xxxxxxxxxx>,	Santosh Shilimkar <ssantosh@xxxxxxxxxx>,	Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxxxxx>,	Liam Girdwood <lgirdwood@xxxxxxxxx>,	Mark Brown <broonie@xxxxxxxxxx>,	Pavel Machek <pavel@xxxxxx>,	Lee Jones <lee.jones@xxxxxxxxxx>,	Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>,	Guenter Roeck <linux@xxxxxxxxxxxx>,	Daniel Lezcano <daniel.lezcano@xxxxxxxxxx>,	Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx>,	Ulf Hansson <ulf.hansson@xxxxxxxxxx>,	alankao@xxxxxxxxxxxxx,	"K . C . Kuen-Chern Lin" <kclin@xxxxxxxxxxxxx>,	Michał Mirosław <mirq-linux@xxxxxxxxxxxx>
 
- From: Dmitry Osipenko <digetx@xxxxxxxxx>
 
- Date: Mon, 31 Jan 2022 02:36:58 +0300
 
- Cc: linux-kernel@xxxxxxxxxxxxxxx,	linux-csky@xxxxxxxxxxxxxxx,	linux-ia64@xxxxxxxxxxxxxxx,	linux-m68k@xxxxxxxxxxxxxxxxxxxx,	linux-mips@xxxxxxxxxxxxxxx,	linux-parisc@xxxxxxxxxxxxxxx,	linux-riscv@xxxxxxxxxxxxxxxxxxx,	linux-sh@xxxxxxxxxxxxxxx,	xen-devel@xxxxxxxxxxxxxxxxxxxx,	linux-acpi@xxxxxxxxxxxxxxx,	linux-pm@xxxxxxxxxxxxxxx,	linux-tegra@xxxxxxxxxxxxxxx
 
- Delivery-date: Sun, 30 Jan 2022 23:37:38 +0000
 
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
 
 
 
Add blocking_notifier_call_chain_is_empty() that returns true if call
chain is empty.
Signed-off-by: Dmitry Osipenko <digetx@xxxxxxxxx>
---
 include/linux/notifier.h |  2 ++
 kernel/notifier.c        | 13 +++++++++++++
 2 files changed, 15 insertions(+)
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index 87069b8459af..d4717bc0ab85 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -173,6 +173,8 @@ extern int blocking_notifier_call_chain_robust(struct 
blocking_notifier_head *nh
 extern int raw_notifier_call_chain_robust(struct raw_notifier_head *nh,
                unsigned long val_up, unsigned long val_down, void *v);
 
+extern bool blocking_notifier_call_chain_is_empty(struct 
blocking_notifier_head *nh);
+
 #define NOTIFY_DONE            0x0000          /* Don't care */
 #define NOTIFY_OK              0x0001          /* Suits me */
 #define NOTIFY_STOP_MASK       0x8000          /* Don't call further */
diff --git a/kernel/notifier.c b/kernel/notifier.c
index ba005ebf4730..4ed6bda8f127 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -323,6 +323,19 @@ int blocking_notifier_call_chain(struct 
blocking_notifier_head *nh,
 }
 EXPORT_SYMBOL_GPL(blocking_notifier_call_chain);
 
+/**
+ *     blocking_notifier_call_chain_is_empty - Check whether notifier chain is 
empty
+ *     @nh: Pointer to head of the blocking notifier chain
+ *
+ *     Checks whether notifier chain is empty.
+ *
+ *     Returns true is notifier chain is empty, false otherwise.
+ */
+bool blocking_notifier_call_chain_is_empty(struct blocking_notifier_head *nh)
+{
+       return !rcu_access_pointer(nh->head);
+}
+
 /*
  *     Raw notifier chain routines.  There is no protection;
  *     the caller must provide it.  Use at your own risk!
-- 
2.34.1
 
    
     |