From patchwork Wed Feb 6 19:40:24 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tejun Heo X-Patchwork-Id: 2107141 Return-Path: X-Original-To: patchwork-linux-mmc@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 61395DF2A1 for ; Wed, 6 Feb 2013 19:58:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964773Ab3BFTuy (ORCPT ); Wed, 6 Feb 2013 14:50:54 -0500 Received: from mail-oa0-f47.google.com ([209.85.219.47]:35386 "EHLO mail-oa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758271Ab3BFTus (ORCPT ); Wed, 6 Feb 2013 14:50:48 -0500 Received: by mail-oa0-f47.google.com with SMTP id o17so1925002oag.20 for ; Wed, 06 Feb 2013 11:50:48 -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=LixhLpcdXQWXeJF9omhxJvpuZKyoJWtB2O6zdDZ6HME=; b=N4w+h4boK0HbTuCB7aWHqGYZTLyccezsJA8m4keZ3h4oFycJRmGq08u+sMziurS+JU vLD2FufKd2soWMNfEYN0VWHmT/bsK1h8kjCBQle7HK+7AsKg+YT7TVZUS15UKOzCXlAq muLCESzWXj7eWreDXjIcRNExbMyL6OqH8CI07e89cFw3zDN5ZbmudZrGUdsNvAf8J0Pr Y1mFbGa5rx+rIa/vaBfTJ4kGGmhX6fcnk+XNPCyVU5wcfhWXGUITjtFhxKZqi0S/uRqP lqvYxDI6OxdNE+tT8amlFmpdbzyydKUKSNO7n/QCJDOwTaHWZLu69bQql6QVO3BiEjbP q+Uw== X-Received: by 10.182.12.39 with SMTP id v7mr22015741obb.47.1360180248434; Wed, 06 Feb 2013 11:50:48 -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.47 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 06 Feb 2013 11:50:47 -0800 (PST) From: Tejun Heo To: akpm@linux-foundation.org Cc: linux-kernel@vger.kernel.org, Tejun Heo , Chris Ball , linux-mmc@vger.kernel.org Subject: [PATCH 52/77] mmc: convert to idr_alloc() Date: Wed, 6 Feb 2013 11:40:24 -0800 Message-Id: <1360179649-22465-53-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-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org Convert to the much saner new idr interface. Only compile tested. Signed-off-by: Tejun Heo Cc: Chris Ball Cc: linux-mmc@vger.kernel.org --- drivers/mmc/core/host.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index ee2e16b..1117de7 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -306,19 +306,20 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) int err; struct mmc_host *host; - if (!idr_pre_get(&mmc_host_idr, GFP_KERNEL)) - return NULL; - host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL); if (!host) return NULL; /* scanning will be enabled when we're ready */ host->rescan_disable = 1; + idr_preload(GFP_KERNEL); spin_lock(&mmc_host_lock); - err = idr_get_new(&mmc_host_idr, host, &host->index); + err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT); + if (err >= 0) + host->index = err; spin_unlock(&mmc_host_lock); - if (err) + idr_preload_end(); + if (err < 0) goto free; dev_set_name(&host->class_dev, "mmc%d", host->index);