From mboxrd@z Thu Jan 1 00:00:00 1970 From: jthumshirn@suse.de (Johannes Thumshirn) Date: Fri, 02 Oct 2015 12:15:45 +0200 Subject: [PATCH 3/5] block: nvme-core: simplify ida usage In-Reply-To: (Lee Duncan's message of "Thu, 1 Oct 2015 11:59:07 -0700") References: Message-ID: Lee Duncan writes: > 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); > } Reviewed-by: Johannes Thumshirn -- Johannes Thumshirn Storage jthumshirn at suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N?rnberg GF: Felix Imend?rffer, Jane Smithard, Graham Norton HRB 21284 (AG N?rnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850 From mboxrd@z Thu Jan 1 00:00:00 1970 From: Johannes Thumshirn Subject: Re: [PATCH 3/5] block: nvme-core: simplify ida usage Date: Fri, 02 Oct 2015 12:15:45 +0200 Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: QUOTED-PRINTABLE Return-path: Received: from mx2.suse.de ([195.135.220.15]:51504 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750709AbbJBKPq convert rfc822-to-8bit (ORCPT ); Fri, 2 Oct 2015 06:15:46 -0400 In-Reply-To: (Lee Duncan's message of "Thu, 1 Oct 2015 11:59:07 -0700") Sender: linux-scsi-owner@vger.kernel.org List-Id: linux-scsi@vger.kernel.org To: Lee Duncan Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, James Bottomley , Tejun Heo , Hannes Reinecke , Christoph Hellwig , Matthew Wilcox , linux-nvme@lists.infradead.org Lee Duncan writes: > 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); > =20 > static int nvme_set_instance(struct nvme_dev *dev) > { > - int instance, error; > + int instance; > =20 > - do { > - if (!ida_pre_get(&nvme_instance_ida, GFP_KERNEL)) > - return -ENODEV; > - > - spin_lock(&dev_list_lock); > - error =3D ida_get_new(&nvme_instance_ida, &instance); > - spin_unlock(&dev_list_lock); > - } while (error =3D=3D -EAGAIN); > - > - if (error) > + instance =3D ida_simple_get(&nvme_instance_ida, 0, 0, GFP_KERNEL); > + if (instance < 0) > return -ENODEV; > =20 > dev->instance =3D instance; > @@ -2734,7 +2726,7 @@ static int nvme_set_instance(struct nvme_dev *d= ev) > 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); > } Reviewed-by: Johannes Thumshirn --=20 Johannes Thumshirn Storage jthumshirn@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg GF: Felix Imend=C3=B6rffer, Jane Smithard, Graham Norton HRB 21284 (AG N=C3=BCrnberg) Key fingerprint =3D EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850 -- To unsubscribe from this list: send the line "unsubscribe linux-scsi" i= n the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752226AbbJBKPs (ORCPT ); Fri, 2 Oct 2015 06:15:48 -0400 Received: from mx2.suse.de ([195.135.220.15]:51504 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750709AbbJBKPq convert rfc822-to-8bit (ORCPT ); Fri, 2 Oct 2015 06:15:46 -0400 From: Johannes Thumshirn To: Lee Duncan Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, James Bottomley , Tejun Heo , Hannes Reinecke , Christoph Hellwig , Matthew Wilcox , linux-nvme@lists.infradead.org Subject: Re: [PATCH 3/5] block: nvme-core: simplify ida usage References: Date: Fri, 02 Oct 2015 12:15:45 +0200 In-Reply-To: (Lee Duncan's message of "Thu, 1 Oct 2015 11:59:07 -0700") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Lee Duncan writes: > 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); > } Reviewed-by: Johannes Thumshirn -- Johannes Thumshirn Storage jthumshirn@suse.de +49 911 74053 689 SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg GF: Felix Imendörffer, Jane Smithard, Graham Norton HRB 21284 (AG Nürnberg) Key fingerprint = EC38 9CAB C2C4 F25D 8600 D0D0 0393 969D 2D76 0850