From patchwork Sun Feb 3 01:20:25 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2085781 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 6E9813FD2B for ; Sun, 3 Feb 2013 01:32:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753845Ab3BCBby (ORCPT ); Sat, 2 Feb 2013 20:31:54 -0500 Received: from mail-pb0-f53.google.com ([209.85.160.53]:39383 "EHLO mail-pb0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753618Ab3BCBWG (ORCPT ); Sat, 2 Feb 2013 20:22:06 -0500 Received: by mail-pb0-f53.google.com with SMTP id un1so2659114pbc.40 for ; Sat, 02 Feb 2013 17:22:04 -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=cuX1q0QK3jYkEWpINThEsMpSPs0gQMo+fYiKSiN5R/o=; b=iEkQ6walR/ajDh72ZoV10sYz7FT7ZQdKrCJB+ExPsRoB8TSuwJz+SaoOr1s74C70Oe DDlSD98MZGL6YxCWq2xbPuCxDfeGDgxLWm2x3oAZNGRFz+HB5liUT8QxJ7/EI//eqjn+ JYW00gD8ZYP+EBrUsugtiIYivTLi3Eib6qSjjOwWV/qSNQeBxJXqZ1JduRCu+nwRbPpe /fY5MHJbRwYRGoofWm999Aiz70uS20lSfT8m+4/YzhK1PKwN1dxCgpliXUAIPQHQHqSV VwbH1IT7hzgeXvmizGKk01vl9qVRARf/l454Rxl8sIam3AMFxg/HhY8/xllrylkxGCP3 BHYw== X-Received: by 10.66.83.8 with SMTP id m8mr19019740pay.40.1359854524558; Sat, 02 Feb 2013 17:22:04 -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 hs2sm13149467pbc.22.2013.02.02.17.22.03 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Sat, 02 Feb 2013 17:22:03 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, rusty@rustcorp.com.au, bfields@fieldses.org, skinsbursky@parallels.com, ebiederm@xmission.com, jmorris@namei.org, axboe@kernel.dk, Tejun Heo , Steve Wise , linux-rdma@vger.kernel.org Subject: [PATCH 24/62] infiniband/cxgb3: convert to idr_alloc() Date: Sat, 2 Feb 2013 17:20:25 -0800 Message-Id: <1359854463-2538-25-git-send-email-tj@kernel.org> X-Mailer: git-send-email 1.8.1 In-Reply-To: <1359854463-2538-1-git-send-email-tj@kernel.org> References: <1359854463-2538-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 Cc: Steve Wise Cc: linux-rdma@vger.kernel.org Reviewed-by: Steve Wise --- This patch depends on an earlier idr changes and I think it would be best to route these together through -mm. Please holler if there's any objection. Thanks. drivers/infiniband/hw/cxgb3/iwch.h | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/drivers/infiniband/hw/cxgb3/iwch.h b/drivers/infiniband/hw/cxgb3/iwch.h index a1c4457..8378622 100644 --- a/drivers/infiniband/hw/cxgb3/iwch.h +++ b/drivers/infiniband/hw/cxgb3/iwch.h @@ -153,19 +153,17 @@ static inline int insert_handle(struct iwch_dev *rhp, struct idr *idr, void *handle, u32 id) { int ret; - int newid; - - do { - if (!idr_pre_get(idr, GFP_KERNEL)) { - return -ENOMEM; - } - spin_lock_irq(&rhp->lock); - ret = idr_get_new_above(idr, handle, id, &newid); - BUG_ON(newid != id); - spin_unlock_irq(&rhp->lock); - } while (ret == -EAGAIN); - - return ret; + + idr_preload(GFP_KERNEL); + spin_lock_irq(&rhp->lock); + + ret = idr_alloc(idr, handle, id, id + 1, GFP_NOWAIT); + + spin_unlock_irq(&rhp->lock); + idr_preload_end(); + + BUG_ON(ret == -ENOSPC); + return ret < 0 ? ret : 0; } static inline void remove_handle(struct iwch_dev *rhp, struct idr *idr, u32 id)