From patchwork Thu Dec 18 14:44:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulf Hansson X-Patchwork-Id: 5514281 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 21FEA9F326 for ; Thu, 18 Dec 2014 14:45:02 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3619B20A25 for ; Thu, 18 Dec 2014 14:45:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B32520A26 for ; Thu, 18 Dec 2014 14:45:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751833AbaLROo5 (ORCPT ); Thu, 18 Dec 2014 09:44:57 -0500 Received: from mail-wg0-f51.google.com ([74.125.82.51]:35414 "EHLO mail-wg0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752365AbaLROoz (ORCPT ); Thu, 18 Dec 2014 09:44:55 -0500 Received: by mail-wg0-f51.google.com with SMTP id x12so1789578wgg.38 for ; Thu, 18 Dec 2014 06:44:54 -0800 (PST) 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:in-reply-to :references; bh=g6Yd2eqUgGmz9zsn9q5GIuyffVpADE36+N1fN++s4I4=; b=joFNjsh0fjfD8EovBOSMrH/qyDDGhsARiqWOr4mxJMdMbsitS2IUVWSLRDxAWWRwhD RSn+3orKQqns1utGaBpvrA2Xlmg96iIznh/xZaH3gwgRunMEMts0sQVQ2Rv3NaW3fCg0 nsNsaS2vMjtbmSLpM0RniUMxYEOgwHPmDbxHq/H3zCiKHESOt2tujqpgD2qDAJQki+CA ZYEt+6rg6fbiN04B4P+m26LQ9Qs6c7zjY9+63FWzwz2Tj4pT71fveAvEDTgtF5xsk7fJ qGrTpT7/Kyi3Pf/0F+EgtEp44QjnYWOt4FQlgfGAmoUBEAkxoqP3m95yhlm444BWD6HL lrcg== X-Gm-Message-State: ALoCoQk6yTWaUjbVs7g4AO4/0pVeS/t7akSW1OmvF30VINt9lVFb15LnwVQvnEakDneozLuoCXV7 X-Received: by 10.181.13.7 with SMTP id eu7mr6005953wid.72.1418913893941; Thu, 18 Dec 2014 06:44:53 -0800 (PST) Received: from localhost.localdomain ([85.235.11.236]) by mx.google.com with ESMTPSA id a14sm25013698wib.22.2014.12.18.06.44.52 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Dec 2014 06:44:53 -0800 (PST) From: Ulf Hansson To: linux-mmc@vger.kernel.org, Ulf Hansson , Chris Ball Subject: [PATCH 6/7] mmc: core: Free all resources for the class device at ->dev_release() Date: Thu, 18 Dec 2014 15:44:35 +0100 Message-Id: <1418913876-13937-7-git-send-email-ulf.hansson@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1418913876-13937-1-git-send-email-ulf.hansson@linaro.org> References: <1418913876-13937-1-git-send-email-ulf.hansson@linaro.org> Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@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=ham 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 To be consistent when freeing data, let's move the idr_remove() call from mmc_free_host() into the ->dev_release() callback for the class device. Signed-off-by: Ulf Hansson --- drivers/mmc/core/host.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c index 45c2dae..fcb7f06 100644 --- a/drivers/mmc/core/host.c +++ b/drivers/mmc/core/host.c @@ -32,10 +32,16 @@ #define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev) +static DEFINE_IDR(mmc_host_idr); +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); mutex_destroy(&host->slot.lock); + spin_lock(&mmc_host_lock); + idr_remove(&mmc_host_idr, host->index); + spin_unlock(&mmc_host_lock); kfree(host); } @@ -54,9 +60,6 @@ void mmc_unregister_host_class(void) class_unregister(&mmc_host_class); } -static DEFINE_IDR(mmc_host_idr); -static DEFINE_SPINLOCK(mmc_host_lock); - #ifdef CONFIG_MMC_CLKGATE static ssize_t clkgate_delay_show(struct device *dev, struct device_attribute *attr, char *buf) @@ -585,10 +588,6 @@ EXPORT_SYMBOL(mmc_remove_host); */ void mmc_free_host(struct mmc_host *host) { - spin_lock(&mmc_host_lock); - idr_remove(&mmc_host_idr, host->index); - spin_unlock(&mmc_host_lock); - put_device(&host->class_dev); }