aboutsummaryrefslogtreecommitdiff
path: root/drivers/mmc/core/sysfs.c
diff options
context:
space:
mode:
authorPierre Ossman <drzeus@drzeus.cx>2007-05-19 14:06:24 +0200
committerPierre Ossman <drzeus@drzeus.cx>2007-07-09 21:28:01 +0200
commitb93931a61a119575f84c33af2438b9384fde9eb7 (patch)
treef424d886c1ef255bfa3d3ca60ae245491e7f9432 /drivers/mmc/core/sysfs.c
parent4101c16a910b15afd190c6bc7d45864461cf5c25 (diff)
mmc: refactor host class handling
Move basic host class device handling to its own file for clarity. Signed-off-by: Pierre Ossman <drzeus@drzeus.cx>
Diffstat (limited to 'drivers/mmc/core/sysfs.c')
-rw-r--r--drivers/mmc/core/sysfs.c84
1 files changed, 3 insertions, 81 deletions
diff --git a/drivers/mmc/core/sysfs.c b/drivers/mmc/core/sysfs.c
index a43a96c2281..fbf99f9a0b8 100644
--- a/drivers/mmc/core/sysfs.c
+++ b/drivers/mmc/core/sysfs.c
@@ -20,11 +20,9 @@
#include <linux/mmc/host.h>
#include "bus.h"
+#include "host.h"
#include "sysfs.h"
-#define to_mmc_driver(d) container_of(d, struct mmc_driver, drv)
-#define cls_dev_to_mmc_host(d) container_of(d, struct mmc_host, class_dev)
-
int mmc_add_attrs(struct mmc_card *card, struct device_attribute *attrs)
{
int error = 0;
@@ -50,82 +48,6 @@ void mmc_remove_attrs(struct mmc_card *card, struct device_attribute *attrs)
device_remove_file(&card->dev, &attrs[i]);
}
-static void mmc_host_classdev_release(struct device *dev)
-{
- struct mmc_host *host = cls_dev_to_mmc_host(dev);
- kfree(host);
-}
-
-static struct class mmc_host_class = {
- .name = "mmc_host",
- .dev_release = mmc_host_classdev_release,
-};
-
-static DEFINE_IDR(mmc_host_idr);
-static DEFINE_SPINLOCK(mmc_host_lock);
-
-/*
- * Internal function. Allocate a new MMC host.
- */
-struct mmc_host *mmc_alloc_host_sysfs(int extra, struct device *dev)
-{
- struct mmc_host *host;
-
- host = kmalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
- if (host) {
- memset(host, 0, sizeof(struct mmc_host) + extra);
-
- host->parent = dev;
- host->class_dev.parent = dev;
- host->class_dev.class = &mmc_host_class;
- device_initialize(&host->class_dev);
- }
-
- return host;
-}
-
-/*
- * Internal function. Register a new MMC host with the MMC class.
- */
-int mmc_add_host_sysfs(struct mmc_host *host)
-{
- int err;
-
- if (!idr_pre_get(&mmc_host_idr, GFP_KERNEL))
- return -ENOMEM;
-
- spin_lock(&mmc_host_lock);
- err = idr_get_new(&mmc_host_idr, host, &host->index);
- spin_unlock(&mmc_host_lock);
- if (err)
- return err;
-
- snprintf(host->class_dev.bus_id, BUS_ID_SIZE,
- "mmc%d", host->index);
-
- return device_add(&host->class_dev);
-}
-
-/*
- * Internal function. Unregister a MMC host with the MMC class.
- */
-void mmc_remove_host_sysfs(struct mmc_host *host)
-{
- device_del(&host->class_dev);
-
- spin_lock(&mmc_host_lock);
- idr_remove(&mmc_host_idr, host->index);
- spin_unlock(&mmc_host_lock);
-}
-
-/*
- * Internal function. Free a MMC host.
- */
-void mmc_free_host_sysfs(struct mmc_host *host)
-{
- put_device(&host->class_dev);
-}
-
static struct workqueue_struct *workqueue;
/*
@@ -154,7 +76,7 @@ static int __init mmc_init(void)
ret = mmc_register_bus();
if (ret == 0) {
- ret = class_register(&mmc_host_class);
+ ret = mmc_register_host_class();
if (ret)
mmc_unregister_bus();
}
@@ -163,7 +85,7 @@ static int __init mmc_init(void)
static void __exit mmc_exit(void)
{
- class_unregister(&mmc_host_class);
+ mmc_unregister_host_class();
mmc_unregister_bus();
destroy_workqueue(workqueue);
}