From: Jenny TC <jenny.tc@intel.com>
To: paul.gortmaker@windriver.com, linux-kernel@vger.kernel.org
Cc: jenny.tc@intel.com
Subject: [PATCH v2] kernel_notifier: register conditional raw notifier
Date: Wed, 8 Aug 2012 20:56:23 +0530 [thread overview]
Message-ID: <1344439583-8243-1-git-send-email-jenny.tc@intel.com> (raw)
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.
Signed-off-by: Jenny TC <jenny.tc@intel.com>
---
v1
* Added API definition
v2
* Added API decalarion
include/linux/notifier.h | 2 ++
kernel/notifier.c | 18 ++++++++++++++++++
2 files changed, 20 insertions(+)
diff --git a/include/linux/notifier.h b/include/linux/notifier.h
index d65746e..67895f0 100644
--- a/include/linux/notifier.h
+++ b/include/linux/notifier.h
@@ -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);
diff --git a/kernel/notifier.c b/kernel/notifier.c
index 2d5cc4c..267e26f 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -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
--
1.7.9.5
reply other threads:[~2012-08-08 9:54 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1344439583-8243-1-git-send-email-jenny.tc@intel.com \
--to=jenny.tc@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paul.gortmaker@windriver.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®