From patchwork Mon Jun 3 01:33:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: chenbaodong X-Patchwork-Id: 10972109 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 297E6912 for ; Mon, 3 Jun 2019 01:35:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1870528893 for ; Mon, 3 Jun 2019 01:35:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0AB78288F8; Mon, 3 Jun 2019 01:35:46 +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 9A92428893 for ; Mon, 3 Jun 2019 01:35:45 +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 1hXbra-0000Q4-Vq; Mon, 03 Jun 2019 01:34:14 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hXbra-0000Pz-4U for xen-devel@lists.xenproject.org; Mon, 03 Jun 2019 01:34:14 +0000 X-Inumbo-ID: ae0ff3b6-859f-11e9-834d-138507bc2d3d Received: from mxnavi-mail.mxnavi.com (unknown [116.90.87.199]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id ae0ff3b6-859f-11e9-834d-138507bc2d3d; Mon, 03 Jun 2019 01:34:09 +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 09:31:55 +0800 From: Baodong Chen To: Date: Mon, 3 Jun 2019 09:33:47 +0800 Message-ID: <1559525627-2701-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 RESEND] 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 make the a little more clear. Signed-off-by: Baodong Chen --- 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..c7b0669 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..2e58bd9 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 = {.head = LIST_HEAD_INIT(name.head)} -#define NOTIFIER_HEAD(name) \ - struct notifier_head name = NOTIFIER_INIT(name) void notifier_chain_register( struct notifier_head *nh, struct notifier_block *nb);