From patchwork Wed Sep 16 17:50:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lee Duncan X-Patchwork-Id: 7198111 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 1E021BEEC1 for ; Wed, 16 Sep 2015 17:55:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 58E81207C6 for ; Wed, 16 Sep 2015 17:55:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CC876203DC for ; Wed, 16 Sep 2015 17:54:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754248AbbIPRyk (ORCPT ); Wed, 16 Sep 2015 13:54:40 -0400 Received: from mx2.suse.de ([195.135.220.15]:51424 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754171AbbIPRvS (ORCPT ); Wed, 16 Sep 2015 13:51:18 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de X-Amavis-Alert: BAD HEADER SECTION, Duplicate header field: "References" Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id E3025ADD0; Wed, 16 Sep 2015 17:51:16 +0000 (UTC) Received: by worklaptop.gonzoleeman.net (Postfix, from userid 1000) id 9B36340C7C; Wed, 16 Sep 2015 10:51:10 -0700 (PDT) From: Lee Duncan To: linux-scsi@vger.kernel.org, James.Bottomley@HansenPartnership.com Cc: linux-kernel@vger.kernel.org, hare@suse.com, jthumshirn@suse.de, hch@infradead.org, Lee Duncan , Ulf Hansson Subject: [PATCH 08/17] Update the mmc driver to use idr helper functions. Date: Wed, 16 Sep 2015 10:50:26 -0700 Message-Id: <5e015e43f03ba302ded85e71db48a8ed6fdc1ac6.1442263513.git.lduncan@suse.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Lee Duncan --- drivers/mmc/core/host.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 99a9c9011c50..5aa2330f074c 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -40,9 +40,8 @@ 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); - spin_unlock(&mmc_host_lock); + + idr_put_index(&mmc_host_idr, &mmc_host_lock, host->index); kfree(host); } @@ -559,17 +558,12 @@ 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); - spin_lock(&mmc_host_lock); - err = idr_alloc(&mmc_host_idr, host, 0, 0, GFP_NOWAIT); - if (err >= 0) - host->index = err; - spin_unlock(&mmc_host_lock); - idr_preload_end(); + err = idr_get_index(&mmc_host_idr, &mmc_host_lock, host); if (err < 0) { kfree(host); return NULL; } + host->index = err; dev_set_name(&host->class_dev, "mmc%d", host->index);