From: Xiaoming Ni <nixiaoming@huawei.com>
To: <trond.myklebust@hammerspace.com>, <anna.schumaker@netapp.com>,
<bfields@fieldses.org>, <jlayton@kernel.org>,
<davem@davemloft.net>, <semen.protsenko@linaro.org>,
<akpm@linux-foundation.org>, <gregkh@linuxfoundation.org>,
<vvs@virtuozzo.com>, <tglx@linutronix.de>
Cc: <nixiaoming@huawei.com>, <dylix.dailei@huawei.com>,
<alex.huangjianhui@huawei.com>, <adobriyan@gmail.com>,
<mingo@kernel.org>, <viresh.kumar@linaro.org>, <luto@kernel.org>,
<arjan@linux.intel.com>, <Nadia.Derbey@bull.net>,
<torvalds@linux-foundation.org>, <stern@rowland.harvard.edu>,
<paulmck@linux.vnet.ibm.com>, <linux-kernel@vger.kernel.org>,
<linux-nfs@vger.kernel.org>, <netdev@vger.kernel.org>,
<stable@kernel.org>
Subject: [PATCH v2 2/3] kernel/notifier.c: remove notifier_chain_cond_register()
Date: Thu, 20 Jun 2019 20:48:33 +0800 [thread overview]
Message-ID: <1561034914-106990-2-git-send-email-nixiaoming@huawei.com> (raw)
In-Reply-To: <1561034914-106990-1-git-send-email-nixiaoming@huawei.com>
The only difference between notifier_chain_cond_register() and
notifier_chain_register() is the lack of warning hints for duplicate
registrations.
Consider using notifier_chain_register() instead of
notifier_chain_cond_register() to avoid duplicate code
Signed-off-by: Xiaoming Ni <nixiaoming@huawei.com>
---
kernel/notifier.c | 17 +----------------
1 file changed, 1 insertion(+), 16 deletions(-)
diff --git a/kernel/notifier.c b/kernel/notifier.c
index 30bedb8..e3d221f 100644
--- a/kernel/notifier.c
+++ b/kernel/notifier.c
@@ -36,21 +36,6 @@ static int notifier_chain_register(struct notifier_block **nl,
return 0;
}
-static int notifier_chain_cond_register(struct notifier_block **nl,
- struct notifier_block *n)
-{
- while ((*nl) != NULL) {
- if ((*nl) == n)
- return 0;
- if (n->priority > (*nl)->priority)
- break;
- nl = &((*nl)->next);
- }
- n->next = *nl;
- rcu_assign_pointer(*nl, n);
- return 0;
-}
-
static int notifier_chain_unregister(struct notifier_block **nl,
struct notifier_block *n)
{
@@ -252,7 +237,7 @@ int blocking_notifier_chain_cond_register(struct blocking_notifier_head *nh,
int ret;
down_write(&nh->rwsem);
- ret = notifier_chain_cond_register(&nh->head, n);
+ ret = notifier_chain_register(&nh->head, n);
up_write(&nh->rwsem);
return ret;
}
--
1.8.5.6
next prev parent reply other threads:[~2019-06-20 12:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-06-20 12:48 [PATCH v2 1/3] kernel/notifier.c: avoid duplicate registration Xiaoming Ni
2019-06-20 12:48 ` Xiaoming Ni [this message]
2019-06-20 12:48 ` [PATCH v2 3/3] kernel/notifier.c: remove blocking_notifier_chain_cond_register() Xiaoming Ni
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1561034914-106990-2-git-send-email-nixiaoming@huawei.com \
--to=nixiaoming@huawei.com \
--cc=Nadia.Derbey@bull.net \
--cc=adobriyan@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=alex.huangjianhui@huawei.com \
--cc=anna.schumaker@netapp.com \
--cc=arjan@linux.intel.com \
--cc=bfields@fieldses.org \
--cc=davem@davemloft.net \
--cc=dylix.dailei@huawei.com \
--cc=gregkh@linuxfoundation.org \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=paulmck@linux.vnet.ibm.com \
--cc=semen.protsenko@linaro.org \
--cc=stable@kernel.org \
--cc=stern@rowland.harvard.edu \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=trond.myklebust@hammerspace.com \
--cc=viresh.kumar@linaro.org \
--cc=vvs@virtuozzo.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).