summaryrefslogtreecommitdiff
path: root/kernel/workqueue.c
diff options
context:
space:
mode:
authorZhen Lei <thunder.leizhen@huawei.com>2021-08-04 06:50:36 +0300
committerTejun Heo <tj@kernel.org>2021-08-10 01:32:38 +0300
commite441b56fe438fd126b9eea7d30c57d3cd3f34e14 (patch)
tree2fdfb38b7bfc4dbada4e4429e199b46335002d93 /kernel/workqueue.c
parent67dc8325370844ffce92aa59abe8b453aa6aa83c (diff)
downloadlinux-e441b56fe438fd126b9eea7d30c57d3cd3f34e14.tar.xz
workqueue: Replace deprecated ida_simple_*() with ida_alloc()/ida_free()
Replace ida_simple_get() with ida_alloc() and ida_simple_remove() with ida_free(), the latter is more concise and intuitive. In addition, if ida_alloc() fails, NULL is returned directly. This eliminates unnecessary initialization of two local variables and an 'if' judgment. Signed-off-by: Zhen Lei <thunder.leizhen@huawei.com> Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'kernel/workqueue.c')
-rw-r--r--kernel/workqueue.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/kernel/workqueue.c b/kernel/workqueue.c
index d3c35e47aa90..29f049463d88 100644
--- a/kernel/workqueue.c
+++ b/kernel/workqueue.c
@@ -1912,14 +1912,14 @@ static void worker_detach_from_pool(struct worker *worker)
*/
static struct worker *create_worker(struct worker_pool *pool)
{
- struct worker *worker = NULL;
- int id = -1;
+ struct worker *worker;
+ int id;
char id_buf[16];
/* ID is needed to determine kthread name */
- id = ida_simple_get(&pool->worker_ida, 0, 0, GFP_KERNEL);
+ id = ida_alloc(&pool->worker_ida, GFP_KERNEL);
if (id < 0)
- goto fail;
+ return NULL;
worker = alloc_worker(pool->node);
if (!worker)
@@ -1954,8 +1954,7 @@ static struct worker *create_worker(struct worker_pool *pool)
return worker;
fail:
- if (id >= 0)
- ida_simple_remove(&pool->worker_ida, id);
+ ida_free(&pool->worker_ida, id);
kfree(worker);
return NULL;
}
@@ -2378,7 +2377,7 @@ woke_up:
set_pf_worker(false);
set_task_comm(worker->task, "kworker/dying");
- ida_simple_remove(&pool->worker_ida, worker->id);
+ ida_free(&pool->worker_ida, worker->id);
worker_detach_from_pool(worker);
kfree(worker);
return 0;