Skip to contentSkip to conversation

kernel_notifier: register conditional raw notifier

PATCH New Jenny TC 1 participant 1 message Aug 8, 2012

lore
Share & tools
lore

Jenny TC

author
#0 lore raw

PATCH v2 1/1 kernel_notifier: register conditional raw notifier

Introduce a new API raw_notifier_chain_cond_register to add a notifier to a raw notifier chain, only if notifier not already present in the chain.

---
v1
* Added API definition
v2
* Added API decalarion

 include/linux/notifier.h |    2 ++
 kernel/notifier.c        |   18 ++++++++++++++++++
 2 files changed, 20 insertions(+)
include/linux/notifier.h +2 -0
index d65746e..67895f0 100644
@@ -124,6 +124,8 @@ extern int srcu_notifier_chain_register(struct srcu_notifier_head *nh,
 extern int blocking_notifier_chain_cond_register(
 		struct blocking_notifier_head *nh,
 		struct notifier_block *nb);
+extern int raw_notifier_chain_cond_register(struct raw_notifier_head *nh,
+		struct notifier_block *nb);
 
 extern int atomic_notifier_chain_unregister(struct atomic_notifier_head *nh,
 		struct notifier_block *nb);
kernel/notifier.c +18 -0
index 2d5cc4c..267e26f 100644
@@ -349,6 +349,24 @@ int raw_notifier_chain_register(struct raw_notifier_head *nh,
 EXPORT_SYMBOL_GPL(raw_notifier_chain_register);
 
 /**
+ *	raw_notifier_chain_cond_register - Cond add notifier to a raw notifier chain
+ *	@nh: Pointer to head of the raw notifier chain
+ *	@n: New entry in notifier chain
+ *
+ *	Adds a notifier to a raw notifier chain, only if not already
+ *	present in the chain.
+ *	All locking must be provided by the caller.
+ *
+ *	Currently always returns zero.
+ */
+int raw_notifier_chain_cond_register(struct raw_notifier_head *nh,
+		struct notifier_block *n)
+{
+	return notifier_chain_cond_register(&nh->head, n);
+}
+EXPORT_SYMBOL_GPL(raw_notifier_chain_cond_register);
+
+/**
  *	raw_notifier_chain_unregister - Remove notifier from a raw notifier chain
  *	@nh: Pointer to head of the raw notifier chain
  *	@n: Entry to remove from notifier chain
Signature · 1 line
1.7.9.5