From patchwork Mon Jun 3 09:58:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenbaodong X-Patchwork-Id: 10972681 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9C36B76 for ; Mon, 3 Jun 2019 10:00:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A8A6287B5 for ; Mon, 3 Jun 2019 10:00:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E208287CE; Mon, 3 Jun 2019 10:00:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A44ED287B5 for ; Mon, 3 Jun 2019 10:00:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXjk9-0004rN-4A; Mon, 03 Jun 2019 09:59:05 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXjk7-0004r9-Kc for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 09:59:03 +0000 X-Inumbo-ID: 35ca41bd-85e6-11e9-8980-bc764e045a96 Received: from mxnavi-mail.mxnavi.com (unknown [116.90.87.199]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 35ca41bd-85e6-11e9-8980-bc764e045a96; Mon, 03 Jun 2019 09:59:02 +0000 (UTC) Received: from localhost.localdomain (61.161.186.150) by mxnavi-mail.mxnavi.com (116.90.87.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1591.10; Mon, 3 Jun 2019 17:56:48 +0800 From: Baodong Chen To: Date: Mon, 3 Jun 2019 17:58:30 +0800 Message-ID: <1559555910-3192-1-git-send-email-chenbaodong@mxnavi.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 X-Originating-IP: [61.161.186.150] X-ClientProxiedBy: mxnavi-mail.mxnavi.com (116.90.87.199) To mxnavi-mail.mxnavi.com (116.90.87.199) Subject: [Xen-devel] [PATCH v1] xen: notifier: refine 'notifier_head', use 'list_head' directly X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Stefano Stabellini , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Tim Deegan , Julien Grall , Jan Beulich , Baodong Chen Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 'notifier_block' can be replaced with 'list_head' when used for 'notifier_head', this makes a little clearer. Signed-off-by: Baodong Chen Acked-by: Jan Beulich --- 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 34488a8..c9ea44d 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 d1ff9b1..0921213 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);