From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756894AbbJAS7x (ORCPT ); Thu, 1 Oct 2015 14:59:53 -0400 Received: from mx2.suse.de ([195.135.220.15]:44825 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756738AbbJAS7u (ORCPT ); Thu, 1 Oct 2015 14:59:50 -0400 X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" From: Lee Duncan To: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Lee Duncan , James Bottomley , Tejun Heo , Hannes Reinecke , Johannes Thumshirn , Christoph Hellwig , Matthew Wilcox , linux-nvme@lists.infradead.org Subject: [PATCH 3/5] block: nvme-core: simplify ida usage Date: Thu, 1 Oct 2015 11:59:07 -0700 Message-Id: X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Simplify ida index allocation and removal by using the ida_simple_* helper functions. Signed-off-by: Lee Duncan --- drivers/block/nvme-core.c | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c index d1d6141920d3..d354a3391e4a 100644 --- a/drivers/block/nvme-core.c +++ b/drivers/block/nvme-core.c @@ -2713,18 +2713,10 @@ static DEFINE_IDA(nvme_instance_ida); static int nvme_set_instance(struct nvme_dev *dev) { - int instance, error; + int instance; - 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); - - if (error) + instance = ida_simple_get(&nvme_instance_ida, 0, 0, GFP_KERNEL); + if (instance < 0) return -ENODEV; dev->instance = instance; @@ -2734,7 +2726,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); + ida_simple_remove(&nvme_instance_ida, dev->instance); spin_unlock(&dev_list_lock); } -- 2.1.4