aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlf Hansson <ulf.hansson@linaro.org>2014-12-18 09:44:35 -0500
committerUlf Hansson <ulf.hansson@linaro.org>2015-01-19 03:56:17 -0500
commite2d1926bad0d0cf7e4b8bf11a8efd1b5fe48893e (patch)
tree830dfb37db0d7d4eeb56b1531e78ab387e183836
parent7f133de1fbe9f496973aaaf22e830433600fa99e (diff)
mmc: core: Free all resources for the class device at ->dev_release()
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 <ulf.hansson@linaro.org>
-rw-r--r--drivers/mmc/core/host.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/drivers/mmc/core/host.c b/drivers/mmc/core/host.c
index 45c2daea71ab..fcb7f06373cf 100644
--- a/drivers/mmc/core/host.c
+++ b/drivers/mmc/core/host.c
@@ -32,10 +32,16 @@
32 32
33#define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev) 33#define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev)
34 34
35static DEFINE_IDR(mmc_host_idr);
36static DEFINE_SPINLOCK(mmc_host_lock);
37
35static void mmc_host_classdev_release(struct device *dev) 38static void mmc_host_classdev_release(struct device *dev)
36{ 39{
37 struct mmc_host *host = cls_dev_to_mmc_host(dev); 40 struct mmc_host *host = cls_dev_to_mmc_host(dev);
38 mutex_destroy(&host->slot.lock); 41 mutex_destroy(&host->slot.lock);
42 spin_lock(&mmc_host_lock);
43 idr_remove(&mmc_host_idr, host->index);
44 spin_unlock(&mmc_host_lock);
39 kfree(host); 45 kfree(host);
40} 46}
41 47
@@ -54,9 +60,6 @@ void mmc_unregister_host_class(void)
54 class_unregister(&mmc_host_class); 60 class_unregister(&mmc_host_class);
55} 61}
56 62
57static DEFINE_IDR(mmc_host_idr);
58static DEFINE_SPINLOCK(mmc_host_lock);
59
60#ifdef CONFIG_MMC_CLKGATE 63#ifdef CONFIG_MMC_CLKGATE
61static ssize_t clkgate_delay_show(struct device *dev, 64static ssize_t clkgate_delay_show(struct device *dev,
62 struct device_attribute *attr, char *buf) 65 struct device_attribute *attr, char *buf)
@@ -585,10 +588,6 @@ EXPORT_SYMBOL(mmc_remove_host);
585 */ 588 */
586void mmc_free_host(struct mmc_host *host) 589void mmc_free_host(struct mmc_host *host)
587{ 590{
588 spin_lock(&mmc_host_lock);
589 idr_remove(&mmc_host_idr, host->index);
590 spin_unlock(&mmc_host_lock);
591
592 put_device(&host->class_dev); 591 put_device(&host->class_dev);
593} 592}
594 593