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: 42461 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f70.google.com (mail-la0-f70.google.com [209.85.215.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 9A03826C8B for ; Thu, 18 Dec 2014 14:45:13 +0000 (UTC) Received: by mail-la0-f70.google.com with SMTP id hs14sf861399lab.1 for ; Thu, 18 Dec 2014 06:45:12 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:subject:date :message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=g6Yd2eqUgGmz9zsn9q5GIuyffVpADE36+N1fN++s4I4=; b=gyDd4CkOqWBgmdddod7aK0Oum9bCECpE0E5L0+D6hT/xh2CrdMwch6RxmmrWSt3C6K gJR8NvPvtnN8ZPvcITZNzx+0ETIxQBUQ/CQyvYZlz1wpMf1tr+lemcrfXGHWKykA1dBq RemWRA3lgYq7eFfNGLqyUGsGD3iSkegOG8uO35r4UnrXy8d4UaeTYjhMPnu/nJXlbnIh kkgiz02N0M7iHdui9pXeCO00VPUEVGSVKMJXnceO1rHp/eAwmRK3uO/+M7dqyuDjig8T bKeXhmkMeJG7ogpIRxg+3pS4jBIeB+ujqGidsoAQCgmPPvYz53JNFqvZOc/2NkG/re1m MxmQ== X-Gm-Message-State: ALoCoQkndrmMAM4YIMmzYE0ztpQKIUnBpsnthND1IvPs7dBFm67dXt+WsiH0mfYDogkzQTkXwvcU X-Received: by 10.180.98.165 with SMTP id ej5mr2180956wib.1.1418913912578; Thu, 18 Dec 2014 06:45:12 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.42.234 with SMTP id r10ls858143lal.17.gmail; Thu, 18 Dec 2014 06:45:12 -0800 (PST) X-Received: by 10.112.156.169 with SMTP id wf9mr2583071lbb.85.1418913912421; Thu, 18 Dec 2014 06:45:12 -0800 (PST) Received: from mail-lb0-f177.google.com (mail-lb0-f177.google.com. [209.85.217.177]) by mx.google.com with ESMTPS id jc11si7122467lac.31.2014.12.18.06.45.12 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Dec 2014 06:45:12 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) client-ip=209.85.217.177; Received: by mail-lb0-f177.google.com with SMTP id b6so1073469lbj.36 for ; Thu, 18 Dec 2014 06:45:12 -0800 (PST) X-Received: by 10.152.234.35 with SMTP id ub3mr2678089lac.70.1418913912352; Thu, 18 Dec 2014 06:45:12 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp1728772lbb; Thu, 18 Dec 2014 06:45:10 -0800 (PST) X-Received: by 10.195.11.6 with SMTP id ee6mr5050728wjd.95.1418913894757; Thu, 18 Dec 2014 06:44:54 -0800 (PST) Received: from mail-wg0-f48.google.com (mail-wg0-f48.google.com. [74.125.82.48]) by mx.google.com with ESMTPS id f9si13885228wiy.38.2014.12.18.06.44.54 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 18 Dec 2014 06:44:54 -0800 (PST) Received-SPF: pass (google.com: domain of ulf.hansson@linaro.org designates 74.125.82.48 as permitted sender) client-ip=74.125.82.48; Received: by mail-wg0-f48.google.com with SMTP id y19so1824759wgg.7 for ; Thu, 18 Dec 2014 06:44:54 -0800 (PST) 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> X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ulf.hansson@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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); }