]> xenbits.xensource.com Git - people/dwmw2/xen.git/commitdiff
notifier: refine 'notifier_head', use 'list_head' directly
authorBaodong Chen <chenbaodong@mxnavi.com>
Mon, 3 Jun 2019 15:16:52 +0000 (17:16 +0200)
committerJan Beulich <jbeulich@suse.com>
Mon, 3 Jun 2019 15:16:52 +0000 (17:16 +0200)
'notifier_block' can be replaced with 'list_head' when used for
'notifier_head', this makes a little clearer.

Signed-off-by: Baodong Chen <chenbaodong@mxnavi.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
xen/common/notifier.c
xen/include/xen/notifier.h

index 34488a84ca8baffcf26daa9bdf2833548d0eb445..c9ea44db419a5c2be92dce6f89eab68948776358 100644 (file)
 void __init notifier_chain_register(
     struct notifier_head *nh, struct notifier_block *n)
 {
-    struct list_head *chain = &nh->head.chain;
+    struct list_head *chain = &nh->head;
     struct notifier_block *nb;
 
-    while ( chain->next != &nh->head.chain )
+    while ( chain->next != &nh->head )
     {
         nb = list_entry(chain->next, struct notifier_block, chain);
         if ( n->priority > nb->priority )
@@ -71,16 +71,16 @@ int notifier_call_chain(
 {
     int ret = NOTIFY_DONE;
     struct list_head *cursor;
-    struct notifier_block *nb;
+    struct notifier_block *nb = NULL;
     bool_t reverse = !!(val & NOTIFY_REVERSE);
 
-    cursor = &(pcursor && *pcursor ? *pcursor : &nh->head)->chain;
+    cursor = pcursor && *pcursor ? &(*pcursor)->chain : &nh->head;
 
     do {
         cursor = reverse ? cursor->prev : cursor->next;
-        nb = list_entry(cursor, struct notifier_block, chain);
-        if ( cursor == &nh->head.chain )
+        if ( cursor == &nh->head )
             break;
+        nb = list_entry(cursor, struct notifier_block, chain);
         ret = nb->notifier_call(nb, val, v);
     } while ( !(ret & NOTIFY_STOP_MASK) );
 
index d1ff9b199ab1afa2f23b6e0fbb2ceacf69509cd6..0921213298be5972c647cc3624a873848e85e8f9 100644 (file)
@@ -29,13 +29,12 @@ struct notifier_block {
 };
 
 struct notifier_head {
-    struct notifier_block head;
+    struct list_head head;
 };
 
-#define NOTIFIER_INIT(name) { .head.chain = LIST_HEAD_INIT(name.head.chain) }
-
 #define NOTIFIER_HEAD(name) \
-    struct notifier_head name = NOTIFIER_INIT(name)
+    struct notifier_head name = { .head = LIST_HEAD_INIT(name.head) }
+
 
 void notifier_chain_register(
     struct notifier_head *nh, struct notifier_block *nb);