[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211206040319.7063-1-yajun.deng@linux.dev>
Date: Mon, 6 Dec 2021 12:03:19 +0800
From: Yajun Deng <yajun.deng@...ux.dev>
To: mingo@...hat.com, peterz@...radead.org, juri.lelli@...hat.com,
vincent.guittot@...aro.org
Cc: dietmar.eggemann@....com, rostedt@...dmis.org, bsegall@...gle.com,
mgorman@...e.de, bristot@...hat.com, linux-kernel@...r.kernel.org,
Yajun Deng <yajun.deng@...ux.dev>
Subject: [PATCH] completion: introduce complete_put() helper function
There are many cases where it is necessary to decrease refcount and test,
then called complete(). So introduce complete_put() helper function.
Signed-off-by: Yajun Deng <yajun.deng@...ux.dev>
---
kernel/sched/completion.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/kernel/sched/completion.c b/kernel/sched/completion.c
index a778554f9dad..dcb737f1edc2 100644
--- a/kernel/sched/completion.c
+++ b/kernel/sched/completion.c
@@ -38,6 +38,13 @@ void complete(struct completion *x)
}
EXPORT_SYMBOL(complete);
+void complete_put(refcount_t *r, struct completion *x)
+{
+ if (refcount_dec_and_test(r))
+ complete(x);
+}
+EXPORT_SYMBOL(complete_put);
+
/**
* complete_all: - signals all threads waiting on this completion
* @x: holds the state of this particular completion
--
2.32.0
Powered by blists - more mailing lists