@@ -2715,15 +2715,7 @@ static int nvme_set_instance(struct nvme_dev *dev)
{
int instance, error;
- do {
- if (!ida_pre_get(&nvme_instance_ida, GFP_KERNEL))
- return -ENODEV;
-
- spin_lock(&dev_list_lock);
- error = ida_get_new(&nvme_instance_ida, &instance);
- spin_unlock(&dev_list_lock);
- } while (error == -EAGAIN);
-
+ error = ida_get_index(&nvme_instance_ida, &dev_list_lock, &instance);
if (error)
return -ENODEV;
@@ -2733,9 +2725,7 @@ static int nvme_set_instance(struct nvme_dev *dev)
static void nvme_release_instance(struct nvme_dev *dev)
{
- spin_lock(&dev_list_lock);
- ida_remove(&nvme_instance_ida, dev->instance);
- spin_unlock(&dev_list_lock);
+ ida_put_index(&nvme_instance_ida, &dev_list_lock, dev->instance);
}
static void nvme_free_namespaces(struct nvme_dev *dev)
Signed-off-by: Lee Duncan <lduncan@suse.com> --- drivers/block/nvme-core.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-)