History

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.

Zhen Lei committed 5 years ago

Commit e441b561 parent 67dc8321 file · +6 −7Browse files

Showing the changes to kernel/workqueue.c (1 of 1 file). Show all

Unified · Split

kernel/workqueue.c+6−7
@@ -1912,14 +1912,14 @@ static void worker_detach_from_pool(struct worker *worker) · 1911 unmodified lines
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) · 28 unmodified lines
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 @@ woke_up: · 416 unmodified lines
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;