diff mbox

[v1,2/6] amso1100: convert to using idr_alloc_cyclic

Message ID 1364390288-30968-3-git-send-email-jlayton@redhat.com (mailing list archive)
State Rejected
Headers show

Commit Message

Jeff Layton March 27, 2013, 1:18 p.m. UTC
(Note: compile-tested only)

Signed-off-by: Jeff Layton <jlayton@redhat.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Steve Wise <swise@opengridcomputing.com>
Cc: Tom Tucker <tom@opengridcomputing.com>
Cc: linux-rdma@vger.kernel.org
---
 drivers/infiniband/hw/amso1100/c2.h    | 1 -
 drivers/infiniband/hw/amso1100/c2_qp.c | 5 ++---
 2 files changed, 2 insertions(+), 4 deletions(-)

Comments

Tejun Heo March 27, 2013, 4:27 p.m. UTC | #1
On Wed, Mar 27, 2013 at 09:18:04AM -0400, Jeff Layton wrote:
>  void c2_init_qp_table(struct c2_dev *c2dev)
>  {
>  	spin_lock_init(&c2dev->qp_table.lock);
> -	idr_init(&c2dev->qp_table.idr);
> +	idr_init_cyclic(&c2dev->qp_table.idr, 0);
>  }

Why is this necessary?  In general, why is idr_init_cyclic()
necessary?

Thanks.
Jeff Layton March 27, 2013, 4:50 p.m. UTC | #2
On Wed, 27 Mar 2013 09:27:55 -0700
Tejun Heo <tj@kernel.org> wrote:

> On Wed, Mar 27, 2013 at 09:18:04AM -0400, Jeff Layton wrote:
> >  void c2_init_qp_table(struct c2_dev *c2dev)
> >  {
> >  	spin_lock_init(&c2dev->qp_table.lock);
> > -	idr_init(&c2dev->qp_table.idr);
> > +	idr_init_cyclic(&c2dev->qp_table.idr, 0);
> >  }
> 
> Why is this necessary?  In general, why is idr_init_cyclic()
> necessary?
> 
> Thanks.
> 

My thinking was that you might want to initialize the "cur" value to an
arbitrary value. All the current users though initialize it to the same
as the "start" value passed into idr_alloc_cyclic. Starting with it at
0 should be fine in all of the existing users.

I'll remove that in v2...

Thanks!
diff mbox

Patch

diff --git a/drivers/infiniband/hw/amso1100/c2.h b/drivers/infiniband/hw/amso1100/c2.h
index ba7a1208..d619d73 100644
--- a/drivers/infiniband/hw/amso1100/c2.h
+++ b/drivers/infiniband/hw/amso1100/c2.h
@@ -265,7 +265,6 @@  struct c2_pd_table {
 struct c2_qp_table {
 	struct idr idr;
 	spinlock_t lock;
-	int last;
 };
 
 struct c2_element {
diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c
index 0ab826b..703b33f 100644
--- a/drivers/infiniband/hw/amso1100/c2_qp.c
+++ b/drivers/infiniband/hw/amso1100/c2_qp.c
@@ -385,8 +385,7 @@  static int c2_alloc_qpn(struct c2_dev *c2dev, struct c2_qp *qp)
 	idr_preload(GFP_KERNEL);
 	spin_lock_irq(&c2dev->qp_table.lock);
 
-	ret = idr_alloc(&c2dev->qp_table.idr, qp, c2dev->qp_table.last++, 0,
-			GFP_NOWAIT);
+	ret = idr_alloc_cyclic(&c2dev->qp_table.idr, qp, 0, 0, GFP_NOWAIT);
 	if (ret >= 0)
 		qp->qpn = ret;
 
@@ -1016,7 +1015,7 @@  out:
 void c2_init_qp_table(struct c2_dev *c2dev)
 {
 	spin_lock_init(&c2dev->qp_table.lock);
-	idr_init(&c2dev->qp_table.idr);
+	idr_init_cyclic(&c2dev->qp_table.idr, 0);
 }
 
 void c2_cleanup_qp_table(struct c2_dev *c2dev)