From patchwork Wed Feb 6 19:40:11 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2107411 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A930EDF2A1 for ; Wed, 6 Feb 2013 20:04:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757971Ab3BFUCn (ORCPT ); Wed, 6 Feb 2013 15:02:43 -0500 Received: from mail-ie0-f169.google.com ([209.85.223.169]:49400 "EHLO mail-ie0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757866Ab3BFTu3 (ORCPT ); Wed, 6 Feb 2013 14:50:29 -0500 Received: by mail-ie0-f169.google.com with SMTP id 13so2430730iea.14 for ; Wed, 06 Feb 2013 11:50:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:sender:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references; bh=r2xGEJP8h2/4mfp1nhouSTmcKa1b3nZpC7OkwYn5w1M=; b=xtGiT558TW6uS2VPmKUbSmj3Hn9ojcgn2BD+TsWZh3DfbHapd2MebgAG9IFaYZqL+a qknz6mkRT7NUj17rrYg90A710p4mI4DZ/jYQmDtyGPKL5iJNoHUm4TomZOEnQgNQPs6u 9/0g0mxgpNE1r1VM/5PRfbpcfhp1Kk9GW3htCo0PnlGdeK94gVlzS0v3mJcgxpABvxu/ fA0T0m1yQ09EFEJlsWMtwXqgJhMs3wf2ByoG7dATOXOhcmS7bUkBA7MRjTdiaP911/6T FdoWYxph3XMBfo4gOhYUA6A7wbbrFvdGLTotfG2a5JZsVem2OzkSMApirTEMWC36byN8 t8Sg== X-Received: by 10.50.191.228 with SMTP id hb4mr8633284igc.37.1360180228689; Wed, 06 Feb 2013 11:50:28 -0800 (PST) Received: from htj.dyndns.org (c-69-181-251-227.hsd1.ca.comcast.net. [69.181.251.227]) by mx.google.com with ESMTPS id l5sm39989590pax.10.2013.02.06.11.50.27 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Feb 2013 11:50:28 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Tejun Heo , Tom Tucker , linux-rdma@vger.kernel.org Subject: [PATCH 39/77] IB/amso1100: convert to idr_alloc() Date: Wed, 6 Feb 2013 11:40:11 -0800 Message-Id: <1360179649-22465-40-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1360179649-22465-1-git-send-email-tj@kernel.org> References: <1360179649-22465-1-git-send-email-tj@kernel.org> Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org Convert to the much saner new idr interface. Only compile tested. Signed-off-by: Tejun Heo Reviewed-by: Steve Wise Cc: Tom Tucker Cc: linux-rdma@vger.kernel.org --- drivers/infiniband/hw/amso1100/c2_qp.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/infiniband/hw/amso1100/c2_qp.c b/drivers/infiniband/hw/amso1100/c2_qp.c index 28cd5cb..0ab826b 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)