Skip to content

Commit ce21aed

Browse files
author
Lai Jiangshan
committed
nvme: use ida_simple_get()
Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
1 parent 30a3c16 commit ce21aed

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

drivers/block/nvme-core.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2508,18 +2508,10 @@ static DEFINE_IDA(nvme_instance_ida);
25082508

25092509
static int nvme_set_instance(struct nvme_dev *dev)
25102510
{
2511-
int instance, error;
2511+
int instance;
25122512

2513-
do {
2514-
if (!ida_pre_get(&nvme_instance_ida, GFP_KERNEL))
2515-
return -ENODEV;
2516-
2517-
spin_lock(&dev_list_lock);
2518-
error = ida_get_new(&nvme_instance_ida, &instance);
2519-
spin_unlock(&dev_list_lock);
2520-
} while (error == -EAGAIN);
2521-
2522-
if (error)
2513+
instance = ida_simple_get(&nvme_instance_ida, 0, 0, GFP_KERNEL);
2514+
if (instance < 0)
25232515
return -ENODEV;
25242516

25252517
dev->instance = instance;
@@ -2528,9 +2520,7 @@ static int nvme_set_instance(struct nvme_dev *dev)
25282520

25292521
static void nvme_release_instance(struct nvme_dev *dev)
25302522
{
2531-
spin_lock(&dev_list_lock);
2532-
ida_remove(&nvme_instance_ida, dev->instance);
2533-
spin_unlock(&dev_list_lock);
2523+
ida_simple_remove(&nvme_instance_ida, dev->instance);
25342524
}
25352525

25362526
static void nvme_free_namespaces(struct nvme_dev *dev)

0 commit comments

Comments
 (0)