From patchwork Mon Apr 18 11:43:52 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 66019 Delivered-To: patches@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1233915qge; Mon, 18 Apr 2016 04:44:09 -0700 (PDT) X-Received: by 10.112.130.41 with SMTP id ob9mr13959172lbb.81.1460979848931; Mon, 18 Apr 2016 04:44:08 -0700 (PDT) Return-Path: Received: from mail-lf0-x233.google.com (mail-lf0-x233.google.com. [2a00:1450:4010:c07::233]) by mx.google.com with ESMTPS id o195si12222707lfo.73.2016.04.18.04.44.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 18 Apr 2016 04:44:08 -0700 (PDT) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::233 as permitted sender) client-ip=2a00:1450:4010:c07::233; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: domain of ulf.hansson@linaro.org designates 2a00:1450:4010:c07::233 as permitted sender) smtp.mailfrom=ulf.hansson@linaro.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: by mail-lf0-x233.google.com with SMTP id j11so212984119lfb.1 for ; Mon, 18 Apr 2016 04:44:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id; bh=zsPJoOtEAMaWTu6kmQADkEM/wWU7thgutyC84d6Isr8=; b=hz8Slyrw7mDVJnBLcQasOzMG2r8+XGtK/Mgs6tFWCK5iFUqbrNuIKempsyTyQnCIfC gHJfmmxKS+DWUTHXEjQzZMLnMzk44BK6id56d+745GcWWcPmRHKxVDigydGcALlgJZ37 13xqPY5QexOu3QpWfQ7/fhOb8yU4ZKMbHd5Oc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=zsPJoOtEAMaWTu6kmQADkEM/wWU7thgutyC84d6Isr8=; b=Dqoc9jQ4Zc9lL1QhGPcFuFqd8nqy6BJRO1NEMaPt4aH01WuzCmUMACyiOmqz9Umxrm jRx2yfY/hHr1VexmO2Lhwj0nKp/U8qfPLY0JwmdW1tV8xS/1/EsPw7g4xChBtRWpURAu 2y6P2AjHlHN+PW9wYJYZyTU7WGNB5k4QjjGMft1d6kYyKZGPdAgfKHkjyURU5y/euiMv bii70H8yGBgSArs8voGVDJuKM8a6JnuW/5wN9ySbcRX+Cr+XyplgzCCd/x2vLIXba8ZT 9Z+u4Rw9Ki+1UGTKPGRPHbSXBzG21nA3Li/q1lMyAFg48/x0J9O7SNMnrOCSYMJOJusr 7XOg== X-Gm-Message-State: AOPr4FWp9W+9hj7dEZzmh9muLYn+jVXPvhtYR4avlZedre/kjh/XesJQz3ZIjd1nll7S+bXAtWU= X-Received: by 10.112.163.135 with SMTP id yi7mr13825306lbb.122.1460979847877; Mon, 18 Apr 2016 04:44:07 -0700 (PDT) Return-Path: Received: from uffe-Latitude-E6430s.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id jo1sm10010232lbc.3.2016.04.18.04.44.06 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 18 Apr 2016 04:44:06 -0700 (PDT) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson Subject: [PATCH 1/3] mmc: core: Convert from IDR to IDA for host indexes Date: Mon, 18 Apr 2016 13:43:52 +0200 Message-Id: <1460979834-24582-1-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 As IDA is more lightweight than IDR, let's convert to use that instead. Signed-off-by: Ulf Hansson --- drivers/mmc/core/host.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) -- 1.9.1 diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 6e4c55a..e0a3ee1 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -33,14 +33,14 @@ #define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev) -static DEFINE_IDR(mmc_host_idr); +static DEFINE_IDA(mmc_host_ida); static DEFINE_SPINLOCK(mmc_host_lock); static void mmc_host_classdev_release(struct device *dev) { struct mmc_host *host = cls_dev_to_mmc_host(dev); spin_lock(&mmc_host_lock); - idr_remove(&mmc_host_idr, host->index); + ida_remove(&mmc_host_ida, host->index); spin_unlock(&mmc_host_lock); kfree(host); } @@ -321,14 +321,20 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev) /* scanning will be enabled when we're ready */ host->rescan_disable = 1; - idr_preload(GFP_KERNEL); + +again: + if (!ida_pre_get(&mmc_host_ida, GFP_KERNEL)) { + kfree(host); + return NULL; + } + spin_lock(&mmc_host_lock); - err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT); - if (err >= 0) - host->index = err; + err = ida_get_new(&mmc_host_ida, &host->index); spin_unlock(&mmc_host_lock); - idr_preload_end(); - if (err < 0) { + + if (err == -EAGAIN) { + goto again; + } else if (err) { kfree(host); return NULL; }