From nobody Thu May 2 09:58:55 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1559270239; cv=none; d=zoho.com; s=zohoarc; b=eJYNlGaH+QsqoM6UvitPF7nhDaJEODJDl7tu/jJnwzpht8cht0Xo4lK26Ap7Npk5vJzA/icYW7TeQqmSmHTsr3z5czLH6wBYeUnvL5BIOrjT//Ed8D97o4HXhVMOzs9Q1LxjvQLeNp0/gOKJ8FnZudPzq8q+vXsuuaODGY9m/X0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1559270239; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=N6nhEWE90Hl6k0ycs9V8Jxiogzm55XKcGy43+BNaymc=; b=OZHz6zyDcfjEfmL+n2/V4/cIPXACTRzKTQG/LMvMFd4kvtRgLsWwIv/XQ8N+E49y7t7pA1nMXYNudZuiKw66IlWkuWRpMhf70dws+QJAQSy9kEN+K1H04y+RXFaUEZvuByyNEhL3XoNY9Mp6iXZ1bOBVSZPNpvK2NpjqzlORxhQ= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1559270239216143.283051159465; Thu, 30 May 2019 19:37:19 -0700 (PDT) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hWXOX-0002My-Iq; Fri, 31 May 2019 02:35:49 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hWXOV-0002Mt-WE for xen-devel@lists.xenproject.org; Fri, 31 May 2019 02:35:48 +0000 Received: from mxnavi-mail.mxnavi.com (unknown [116.90.87.199]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id c9d7a5b6-834c-11e9-8980-bc764e045a96; Fri, 31 May 2019 02:35:45 +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; Fri, 31 May 2019 10:33:31 +0800 X-Inumbo-ID: c9d7a5b6-834c-11e9-8980-bc764e045a96 From: Baodong Chen To: Date: Fri, 31 May 2019 10:35:28 +0800 Message-ID: <1559270128-28496-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] 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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" Signed-off-by: Baodong Chen --- xen/common/notifier.c | 25 ++++++------------------- xen/include/xen/notifier.h | 21 +++++++++++++++------ 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/xen/common/notifier.c b/xen/common/notifier.c index 34488a8..f959a79 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 =3D &nh->head.chain; + struct list_head *chain =3D &nh->head; struct notifier_block *nb; =20 - while ( chain->next !=3D &nh->head.chain ) + while ( chain->next !=3D &nh->head ) { nb =3D list_entry(chain->next, struct notifier_block, chain); if ( n->priority > nb->priority ) @@ -35,19 +35,6 @@ void __init notifier_chain_register( list_add(&n->chain, chain); } =20 -/** - * notifier_chain_unregister - Remove notifier from a raw notifier chain - * @nh: Pointer to head of the raw notifier chain - * @n: Entry to remove from notifier chain - * - * Removes a notifier from a raw notifier chain. - * All locking must be provided by the caller. - */ -void __init notifier_chain_unregister( - struct notifier_head *nh, struct notifier_block *n) -{ - list_del(&n->chain); -} =20 /** * notifier_call_chain - Informs the registered notifiers about an event. @@ -71,16 +58,16 @@ int notifier_call_chain( { int ret =3D NOTIFY_DONE; struct list_head *cursor; - struct notifier_block *nb; + struct notifier_block *nb =3D NULL; bool_t reverse =3D !!(val & NOTIFY_REVERSE); =20 - cursor =3D &(pcursor && *pcursor ? *pcursor : &nh->head)->chain; + cursor =3D (pcursor && *pcursor ? &(*pcursor)->chain : &nh->head); =20 do { cursor =3D reverse ? cursor->prev : cursor->next; - nb =3D list_entry(cursor, struct notifier_block, chain); - if ( cursor =3D=3D &nh->head.chain ) + if ( cursor =3D=3D &nh->head ) break; + nb =3D list_entry(cursor, struct notifier_block, chain); ret =3D nb->notifier_call(nb, val, v); } while ( !(ret & NOTIFY_STOP_MASK) ); =20 diff --git a/xen/include/xen/notifier.h b/xen/include/xen/notifier.h index d1ff9b1..b1961cb 100644 --- a/xen/include/xen/notifier.h +++ b/xen/include/xen/notifier.h @@ -29,18 +29,27 @@ struct notifier_block { }; =20 struct notifier_head { - struct notifier_block head; + struct list_head head; }; =20 -#define NOTIFIER_INIT(name) { .head.chain =3D LIST_HEAD_INIT(name.head.cha= in) } +#define NOTIFIER_HEAD(name) = \ + struct notifier_head name =3D {.head =3D LIST_HEAD_INIT(name.head)} =20 -#define NOTIFIER_HEAD(name) \ - struct notifier_head name =3D NOTIFIER_INIT(name) =20 void notifier_chain_register( struct notifier_head *nh, struct notifier_block *nb); -void notifier_chain_unregister( - struct notifier_head *nh, struct notifier_block *nb); + +/** + * notifier_chain_unregister - Remove notifier from a raw notifier chain + * @n: Entry to remove from notifier chain + * + * Removes a notifier from a raw notifier chain. + * All locking must be provided by the caller. + */ +static inline void notifier_chain_unregister(struct notifier_block *n) +{ + list_del(&n->chain); +} =20 int notifier_call_chain( struct notifier_head *nh, unsigned long val, void *v, --=20 2.7.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel