From: Tejun Heo Date: Thu, 7 Feb 2013 01:31:40 +0000 (+1100) Subject: IB/amso1100: convert to idr_alloc() X-Git-Tag: next-20130218~1^2~127 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=57e71013f8192a9e744d19b73122fda6b3e86a9a;p=karo-tx-linux.git IB/amso1100: convert to idr_alloc() Convert to the much saner new idr interface. Only compile tested. Signed-off-by: Tejun Heo Reviewed-by: Steve Wise Cc: Tom Tucker Signed-off-by: Andrew Morton --- diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c index 28cd5cb51859..0ab826b280b2 100644 --- a/drivers/infiniband/hw/amso1100/c2_qp.c +++ b/drivers/infiniband/hw/amso1100/c2_qp.c @@ -382,14 +382,17 @@ static int c2_alloc_qpn(struct c2_dev *c2dev, struct c2_qp *qp) { int ret; - do { - spin_lock_irq(&c2dev->qp_table.lock); - ret = idr_get_new_above(&c2dev->qp_table.idr, qp, - c2dev->qp_table.last++, &qp->qpn); - spin_unlock_irq(&c2dev->qp_table.lock); - } while ((ret == -EAGAIN) && - idr_pre_get(&c2dev->qp_table.idr, GFP_KERNEL)); - return ret; + 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); + if (ret >= 0) + qp->qpn = ret; + + spin_unlock_irq(&c2dev->qp_table.lock); + idr_preload_end(); + return ret < 0 ? ret : 0; } static void c2_free_qpn(struct c2_dev *c2dev, int qpn)