[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen staging] notifier: refine 'notifier_head', use 'list_head' directly



commit 98e6f19b2283b750fba58948282babaf3c4815fb
Author:     Baodong Chen <chenbaodong@xxxxxxxxxx>
AuthorDate: Mon Jun 3 17:16:52 2019 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Mon Jun 3 17:16:52 2019 +0200

    notifier: refine 'notifier_head', use 'list_head' directly
    
    'notifier_block' can be replaced with 'list_head' when used for
    'notifier_head', this makes a little clearer.
    
    Signed-off-by: Baodong Chen <chenbaodong@xxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/common/notifier.c      | 12 ++++++------
 xen/include/xen/notifier.h |  7 +++----
 2 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/xen/common/notifier.c b/xen/common/notifier.c
index 34488a84ca..c9ea44db41 100644
--- a/xen/common/notifier.c
+++ b/xen/common/notifier.c
@@ -21,10 +21,10 @@
 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) );
 
diff --git a/xen/include/xen/notifier.h b/xen/include/xen/notifier.h
index d1ff9b199a..0921213298 100644
--- a/xen/include/xen/notifier.h
+++ b/xen/include/xen/notifier.h
@@ -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);
--
generated by git-patchbot for /home/xen/git/xen.git#staging

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.