Skip to content

Commit e441b56

Browse files
Zhen Leihtejun
authored andcommitted
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 <[email protected]> Signed-off-by: Tejun Heo <[email protected]>
1 parent 67dc832 commit e441b56

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

kernel/workqueue.c

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1912,14 +1912,14 @@ static void worker_detach_from_pool(struct worker *worker)
19121912
*/
19131913
static struct worker *create_worker(struct worker_pool *pool)
19141914
{
1915-
struct worker *worker = NULL;
1916-
int id = -1;
1915+
struct worker *worker;
1916+
int id;
19171917
char id_buf[16];
19181918

19191919
/* ID is needed to determine kthread name */
1920-
id = ida_simple_get(&pool->worker_ida, 0, 0, GFP_KERNEL);
1920+
id = ida_alloc(&pool->worker_ida, GFP_KERNEL);
19211921
if (id < 0)
1922-
goto fail;
1922+
return NULL;
19231923

19241924
worker = alloc_worker(pool->node);
19251925
if (!worker)
@@ -1954,8 +1954,7 @@ static struct worker *create_worker(struct worker_pool *pool)
19541954
return worker;
19551955

19561956
fail:
1957-
if (id >= 0)
1958-
ida_simple_remove(&pool->worker_ida, id);
1957+
ida_free(&pool->worker_ida, id);
19591958
kfree(worker);
19601959
return NULL;
19611960
}
@@ -2378,7 +2377,7 @@ static int worker_thread(void *__worker)
23782377
set_pf_worker(false);
23792378

23802379
set_task_comm(worker->task, "kworker/dying");
2381-
ida_simple_remove(&pool->worker_ida, worker->id);
2380+
ida_free(&pool->worker_ida, worker->id);
23822381
worker_detach_from_pool(worker);
23832382
kfree(worker);
23842383
return 0;

0 commit comments

Comments
 (0)