From patchwork Wed Feb 6 19:40:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2107361 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork1.kernel.org (Postfix) with ESMTP id 8BDAC3FCFC for ; Wed, 6 Feb 2013 20:02:58 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 66697E66F5 for ; Wed, 6 Feb 2013 12:02:58 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-da0-f44.google.com (mail-da0-f44.google.com [209.85.210.44]) by gabe.freedesktop.org (Postfix) with ESMTP id E7D19E6778 for ; Wed, 6 Feb 2013 12:01:31 -0800 (PST) Received: by mail-da0-f44.google.com with SMTP id z20so819592dae.3 for ; Wed, 06 Feb 2013 12:01:31 -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=E0jSdTkiOGGAdocpC9nYjb7yfyvi/Q3QzK501+Jyjgc=; b=Onmz+ABt8rwt9dJ7wmrwFt3RJYkOzHJu7OBu4w2Q5n/dEZSKNt+WAdmUZKpSP1oWDx NxG11effkrMrEGs+CCRoU85r1oWLva2CslkkMfDBpDPN9oaX6FM8LIAoVDZy4Fm7wEnY KHLwAVg1HT7Oo1s7HYF3UlzXNFPxgOe3QovxdTTtkmGY68NvErAH+KGsh/wtw6nahCaI 4DsYmoZfe5BF7+Dk6ntEgaXAQgIbWpA47AcptEs//oRthVTiLsWNhwdM5bBZMAzGqv4G T1J+035PEEakfTGW6n4eSLVETUxqaR2c8BDT9VsbX4ttK6ioOo3IhDVGESEb7Rp5AzaC TARw== X-Received: by 10.66.74.234 with SMTP id x10mr36331054pav.10.1360180223322; Wed, 06 Feb 2013 11:50:23 -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.21 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Feb 2013 11:50:22 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Subject: [PATCH 36/77] drm/vmwgfx: convert to idr_alloc() Date: Wed, 6 Feb 2013 11:40:08 -0800 Message-Id: <1360179649-22465-37-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> Cc: Tejun Heo , linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Convert to the much saner new idr interface. Only compile tested. Signed-off-by: Tejun Heo Cc: David Airlie Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/vmwgfx/vmwgfx_resource.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c index e01a17b..c9d0676 100644 --- a/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_resource.c @@ -177,17 +177,16 @@ int vmw_resource_alloc_id(struct vmw_resource *res) BUG_ON(res->id != -1); - do { - if (unlikely(idr_pre_get(idr, GFP_KERNEL) == 0)) - return -ENOMEM; - - write_lock(&dev_priv->resource_lock); - ret = idr_get_new_above(idr, res, 1, &res->id); - write_unlock(&dev_priv->resource_lock); + idr_preload(GFP_KERNEL); + write_lock(&dev_priv->resource_lock); - } while (ret == -EAGAIN); + ret = idr_alloc(idr, res, 1, 0, GFP_NOWAIT); + if (ret >= 0) + res->id = ret; - return ret; + write_unlock(&dev_priv->resource_lock); + idr_preload_end(); + return ret < 0 ? ret : 0; } /**