From patchwork Wed Feb 6 19:40:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2106901 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 0B2853FCFC for ; Wed, 6 Feb 2013 19:52:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E7EC3E65FB for ; Wed, 6 Feb 2013 11:52:18 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-oa0-f52.google.com (mail-oa0-f52.google.com [209.85.219.52]) by gabe.freedesktop.org (Postfix) with ESMTP id 171F5E5F8F for ; Wed, 6 Feb 2013 11:50:19 -0800 (PST) Received: by mail-oa0-f52.google.com with SMTP id k14so1900409oag.25 for ; Wed, 06 Feb 2013 11:50:18 -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=bBSUoize8HxnOZNYFSdBVkhNqu8nGyzmrmopDSqvpuY=; b=UuQT8judVsruz3IjsDTN+V+SIXoRmWjY0CoIzftmC0VAZLHuJ2isKafI05bsu6eqbe 7UXqTHse3GhsAYAfm445GujZ+HqsaqUkXNzjiO8b6Amy7X9Te1lcLbo5GUKWIFgLTpdR XkUh8waxqyjCZUax6UhUtp4zxf036+Frh9RiV46p4yBnDHhL0l/2Y7gw0GbJT9gZuHuY 64ONKtfuf1RLysSbHXZ86I39N0I9NRMaZJ8OjF9G4BvbJpRlH/JgsaT6vMpr5r3zCpHw eM0X23CofQQbctvWCI5NXxpp72dG6KC/tUIgUJqXCLPTi9zh8ZQ9jJlHH8olgZbhe+6j 8G1Q== X-Received: by 10.60.21.101 with SMTP id u5mr4474980oee.71.1360180218402; Wed, 06 Feb 2013 11:50:18 -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.16 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Feb 2013 11:50:17 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Subject: [PATCH 33/77] drm/i915: convert to idr_alloc() Date: Wed, 6 Feb 2013 11:40:05 -0800 Message-Id: <1360179649-22465-34-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 Acked-by: Daniel Vetter Cc: David Airlie Cc: dri-devel@lists.freedesktop.org --- drivers/gpu/drm/i915/i915_gem_context.c | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c index a3f06bc..27e586a 100644 --- a/drivers/gpu/drm/i915/i915_gem_context.c +++ b/drivers/gpu/drm/i915/i915_gem_context.c @@ -144,7 +144,7 @@ create_hw_context(struct drm_device *dev, { struct drm_i915_private *dev_priv = dev->dev_private; struct i915_hw_context *ctx; - int ret, id; + int ret; ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); if (ctx == NULL) @@ -169,22 +169,11 @@ create_hw_context(struct drm_device *dev, ctx->file_priv = file_priv; -again: - if (idr_pre_get(&file_priv->context_idr, GFP_KERNEL) == 0) { - ret = -ENOMEM; - DRM_DEBUG_DRIVER("idr allocation failed\n"); - goto err_out; - } - - ret = idr_get_new_above(&file_priv->context_idr, ctx, - DEFAULT_CONTEXT_ID + 1, &id); - if (ret == 0) - ctx->id = id; - - if (ret == -EAGAIN) - goto again; - else if (ret) + ret = idr_alloc(&file_priv->context_idr, ctx, DEFAULT_CONTEXT_ID + 1, 0, + GFP_KERNEL); + if (ret < 0) goto err_out; + ctx->id = ret; return ctx;