Linux Headquarters
[ Register ]
[ About us ] [ Home Page ]

Advertisement
[ Kernel ] [ Documentation ] [ Links ] [ Books ]

Advertisement

Kernel v2.6.26-rc1 /kernel/notifier.c

Filename:/kernel/notifier.c
Lines Added:38
Lines Deleted:0
Also changed in: (Previous) 2.6.25-git20  2.6.25-git19  2.6.25-git18  2.6.25-git17  2.6.25-git16  2.6.25-git15 
(Following) 2.6.26-rc2  2.6.26-rc3  2.6.26-rc4  2.6.26-rc5  2.6.26-rc6  2.6.26-rc7 

Location
[  2.6.26-rc1
  [  kernel
     o  notifier.c

Patch

diff --git a/kernel/notifier.c b/kernel/notifier.c
index 643360d..823be11 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -31,6 +31,21 @@ static int notifier_chain_register(struct notifier_block **nl,
    return 0;
 }
 
+static int notifier_chain_cond_register(struct notifier_block **nl,
+      struct notifier_block *n)
+{
+   while ((*nl) != NULL) {
+      if ((*nl) == n)
+         return 0;
+      if (n->priority > (*nl)->priority)
+         break;
+      nl = &((*nl)->next);
+   }
+   n->next = *nl;
+   rcu_assign_pointer(*nl, n);
+   return 0;
+}
+
 static int notifier_chain_unregister(struct notifier_block **nl,
       struct notifier_block *n)
 {
@@ -205,6 +220,29 @@ int blocking_notifier_chain_register(struct blocking_notifier_head *nh,
 EXPORT_SYMBOL_GPL(blocking_notifier_chain_register);
 
 /**
+ *   blocking_notifier_chain_cond_register - Cond add notifier to a blocking notifier chain
+ *   @nh: Pointer to head of the blocking notifier chain
+ *   @n: New entry in notifier chain
+ *
+ *   Adds a notifier to a blocking notifier chain, only if not already
+ *   present in the chain.
+ *   Must be called in process context.
+ *
+ *   Currently always returns zero.
+ */
+int blocking_notifier_chain_cond_register(struct blocking_notifier_head *nh,
+      struct notifier_block *n)
+{
+   int ret;
+
+   down_write(&nh->rwsem);
+   ret = notifier_chain_cond_register(&nh->head, n);
+   up_write(&nh->rwsem);
+   return ret;
+}
+EXPORT_SYMBOL_GPL(blocking_notifier_chain_cond_register);
+
+/**
  *   blocking_notifier_chain_unregister - Remove notifier from a blocking notifier chain
  *   @nh: Pointer to head of the blocking notifier chain
  *   @n: Entry to remove from notifier chain


Comments: webmaster (at) linuxhq.com.
Advertising: banners (at) linuxhq.com.
Compilation ©1998-2008 Linux Headquarters, Inc.