From patchwork Wed Feb 6 19:40:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2107391 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 8A5EADF2A1 for ; Wed, 6 Feb 2013 20:03:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758041Ab3BFUDO (ORCPT ); Wed, 6 Feb 2013 15:03:14 -0500 Received: from mail-da0-f44.google.com ([209.85.210.44]:51040 "EHLO mail-da0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758032Ab3BFUDM (ORCPT ); Wed, 6 Feb 2013 15:03:12 -0500 Received: by mail-da0-f44.google.com with SMTP id z20so820061dae.3 for ; Wed, 06 Feb 2013 12:03:11 -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=ZMfZBP1ZtngiyqqUodTFOskrah0M7QVT3hPFBu7Icu8=; b=dtYh0uGnk+B/62dHL+hQX8Mceu90zZJetRuyQHq1uQQHA/Wald4ecQ/0V+EOi3YQg0 QjaYqFadn+8aTyFsd+yVgjn5bxUa0LNUsJHnN++JcwQZnSpcvjCfKEjEdjZ4iaSjntWM K/um0TUejxxhVWdvIIb1qgMali3bVBZGutwtwRye+8rVmuoFqSRLVhZIm8L8sA7rvPuQ KIg8DtA/CLz6XTBnv0VKP+/gE8JQ1rrSq0AJomz7kZCHCMZwT0OUVQ23Mqc4zRRZlaVa i88hrWCCCnu/u4X2WnZq46qpznxDHD+tBaEHNXqV0yuOJqTE/A4BA7R1xk3jGWqUkBbg uN4g== X-Received: by 10.66.73.164 with SMTP id m4mr78945400pav.12.1360180230178; Wed, 06 Feb 2013 11:50:30 -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.28 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Feb 2013 11:50:29 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Tejun Heo , linux-rdma@vger.kernel.org Subject: [PATCH 40/77] IB/cxgb3: convert to idr_alloc() Date: Wed, 6 Feb 2013 11:40:12 -0800 Message-Id: <1360179649-22465-41-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: linux-rdma@vger.kernel.org --- 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)