Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
[linux-drm-fsl-dcu.git] / drivers / mmc / mmc_sysfs.c
index 3f4a66ca9555e6c354c468266d22609adf56c628..e334acd045bced56ac88edf5850bde81297d8087 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/init.h>
 #include <linux/device.h>
 #include <linux/idr.h>
+#include <linux/workqueue.h>
 
 #include <linux/mmc/card.h>
 #include <linux/mmc/host.h>
@@ -80,7 +81,7 @@ static int mmc_bus_match(struct device *dev, struct device_driver *drv)
 }
 
 static int
-mmc_bus_hotplug(struct device *dev, char **envp, int num_envp, char *buf,
+mmc_bus_uevent(struct device *dev, char **envp, int num_envp, char *buf,
                int buf_size)
 {
        struct mmc_card *card = dev_to_mmc_card(dev);
@@ -136,17 +137,7 @@ static int mmc_bus_resume(struct device *dev)
        return ret;
 }
 
-static struct bus_type mmc_bus_type = {
-       .name           = "mmc",
-       .dev_attrs      = mmc_dev_attrs,
-       .match          = mmc_bus_match,
-       .hotplug        = mmc_bus_hotplug,
-       .suspend        = mmc_bus_suspend,
-       .resume         = mmc_bus_resume,
-};
-
-
-static int mmc_drv_probe(struct device *dev)
+static int mmc_bus_probe(struct device *dev)
 {
        struct mmc_driver *drv = to_mmc_driver(dev->driver);
        struct mmc_card *card = dev_to_mmc_card(dev);
@@ -154,7 +145,7 @@ static int mmc_drv_probe(struct device *dev)
        return drv->probe(card);
 }
 
-static int mmc_drv_remove(struct device *dev)
+static int mmc_bus_remove(struct device *dev)
 {
        struct mmc_driver *drv = to_mmc_driver(dev->driver);
        struct mmc_card *card = dev_to_mmc_card(dev);
@@ -164,6 +155,16 @@ static int mmc_drv_remove(struct device *dev)
        return 0;
 }
 
+static struct bus_type mmc_bus_type = {
+       .name           = "mmc",
+       .dev_attrs      = mmc_dev_attrs,
+       .match          = mmc_bus_match,
+       .uevent         = mmc_bus_uevent,
+       .probe          = mmc_bus_probe,
+       .remove         = mmc_bus_remove,
+       .suspend        = mmc_bus_suspend,
+       .resume         = mmc_bus_resume,
+};
 
 /**
  *     mmc_register_driver - register a media driver
@@ -172,8 +173,6 @@ static int mmc_drv_remove(struct device *dev)
 int mmc_register_driver(struct mmc_driver *drv)
 {
        drv->drv.bus = &mmc_bus_type;
-       drv->drv.probe = mmc_drv_probe;
-       drv->drv.remove = mmc_drv_remove;
        return driver_register(&drv->drv);
 }
 
@@ -200,7 +199,7 @@ void mmc_init_card(struct mmc_card *card, struct mmc_host *host)
        memset(card, 0, sizeof(struct mmc_card));
        card->host = host;
        device_initialize(&card->dev);
-       card->dev.parent = card->host->dev;
+       card->dev.parent = mmc_dev(host);
        card->dev.bus = &mmc_bus_type;
        card->dev.release = mmc_release_card;
 }
@@ -243,7 +242,7 @@ void mmc_remove_card(struct mmc_card *card)
 }
 
 
-static void mmc_host_classdev_release(struct class_device *dev)
+static void mmc_host_classdev_release(struct device *dev)
 {
        struct mmc_host *host = cls_dev_to_mmc_host(dev);
        kfree(host);
@@ -251,7 +250,7 @@ static void mmc_host_classdev_release(struct class_device *dev)
 
 static struct class mmc_host_class = {
        .name           = "mmc_host",
-       .release        = mmc_host_classdev_release,
+       .dev_release    = mmc_host_classdev_release,
 };
 
 static DEFINE_IDR(mmc_host_idr);
@@ -268,10 +267,10 @@ struct mmc_host *mmc_alloc_host_sysfs(int extra, struct device *dev)
        if (host) {
                memset(host, 0, sizeof(struct mmc_host) + extra);
 
-               host->dev = dev;
-               host->class_dev.dev = host->dev;
+               host->parent = dev;
+               host->class_dev.parent = dev;
                host->class_dev.class = &mmc_host_class;
-               class_device_initialize(&host->class_dev);
+               device_initialize(&host->class_dev);
        }
 
        return host;
@@ -293,10 +292,10 @@ int mmc_add_host_sysfs(struct mmc_host *host)
        if (err)
                return err;
 
-       snprintf(host->class_dev.class_id, BUS_ID_SIZE,
+       snprintf(host->class_dev.bus_id, BUS_ID_SIZE,
                 "mmc%d", host->index);
 
-       return class_device_add(&host->class_dev);
+       return device_add(&host->class_dev);
 }
 
 /*
@@ -304,7 +303,7 @@ int mmc_add_host_sysfs(struct mmc_host *host)
  */
 void mmc_remove_host_sysfs(struct mmc_host *host)
 {
-       class_device_del(&host->class_dev);
+       device_del(&host->class_dev);
 
        spin_lock(&mmc_host_lock);
        idr_remove(&mmc_host_idr, host->index);
@@ -316,13 +315,36 @@ void mmc_remove_host_sysfs(struct mmc_host *host)
  */
 void mmc_free_host_sysfs(struct mmc_host *host)
 {
-       class_device_put(&host->class_dev);
+       put_device(&host->class_dev);
 }
 
+static struct workqueue_struct *workqueue;
+
+/*
+ * Internal function. Schedule delayed work in the MMC work queue.
+ */
+int mmc_schedule_delayed_work(struct delayed_work *work, unsigned long delay)
+{
+       return queue_delayed_work(workqueue, work, delay);
+}
+
+/*
+ * Internal function. Flush all scheduled work from the MMC work queue.
+ */
+void mmc_flush_scheduled_work(void)
+{
+       flush_workqueue(workqueue);
+}
 
 static int __init mmc_init(void)
 {
-       int ret = bus_register(&mmc_bus_type);
+       int ret;
+
+       workqueue = create_singlethread_workqueue("kmmcd");
+       if (!workqueue)
+               return -ENOMEM;
+
+       ret = bus_register(&mmc_bus_type);
        if (ret == 0) {
                ret = class_register(&mmc_host_class);
                if (ret)
@@ -335,6 +357,7 @@ static void __exit mmc_exit(void)
 {
        class_unregister(&mmc_host_class);
        bus_unregister(&mmc_bus_type);
+       destroy_workqueue(workqueue);
 }
 
 module_init(mmc_init);