]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/mmc/core/host.c
mmc: use correct unregister function for led trigger
[linux-2.6-omap-h63xx.git] / drivers / mmc / core / host.c
index 1433d95c40bb6d660c2f69115390b2a2fc916c44..c65d203a846d6e91dc5689e0bee82311474468a2 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/err.h>
 #include <linux/idr.h>
 #include <linux/pagemap.h>
+#include <linux/leds.h>
 
 #include <linux/mmc/host.h>
 
@@ -58,12 +59,10 @@ struct mmc_host *mmc_alloc_host(int extra, struct device *dev)
 {
        struct mmc_host *host;
 
-       host = kmalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
+       host = kzalloc(sizeof(struct mmc_host) + extra, GFP_KERNEL);
        if (!host)
                return NULL;
 
-       memset(host, 0, sizeof(struct mmc_host) + extra);
-
        host->parent = dev;
        host->class_dev.parent = dev;
        host->class_dev.class = &mmc_host_class;
@@ -93,11 +92,18 @@ EXPORT_SYMBOL(mmc_alloc_host);
 /**
  *     mmc_add_host - initialise host hardware
  *     @host: mmc host
+ *
+ *     Register the host with the driver model. The host must be
+ *     prepared to start servicing requests before this function
+ *     completes.
  */
 int mmc_add_host(struct mmc_host *host)
 {
        int err;
 
+       WARN_ON((host->caps & MMC_CAP_SDIO_IRQ) &&
+               !host->ops->enable_sdio_irq);
+
        if (!idr_pre_get(&mmc_host_idr, GFP_KERNEL))
                return -ENOMEM;
 
@@ -110,6 +116,8 @@ int mmc_add_host(struct mmc_host *host)
        snprintf(host->class_dev.bus_id, BUS_ID_SIZE,
                 "mmc%d", host->index);
 
+       led_trigger_register_simple(host->class_dev.bus_id, &host->led);
+
        err = device_add(&host->class_dev);
        if (err)
                return err;
@@ -126,7 +134,8 @@ EXPORT_SYMBOL(mmc_add_host);
  *     @host: mmc host
  *
  *     Unregister and remove all cards associated with this host,
- *     and power down the MMC bus.
+ *     and power down the MMC bus. No new requests will be issued
+ *     after this function has returned.
  */
 void mmc_remove_host(struct mmc_host *host)
 {
@@ -134,6 +143,8 @@ void mmc_remove_host(struct mmc_host *host)
 
        device_del(&host->class_dev);
 
+       led_trigger_unregister_simple(host->led);
+
        spin_lock(&mmc_host_lock);
        idr_remove(&mmc_host_idr, host->index);
        spin_unlock(&mmc_host_lock);