mmc: core: export sysmbol "mmc_host_rescan"
authorlintao <lintao@rock-chips.com>
Tue, 18 Mar 2014 01:43:18 +0000 (09:43 +0800)
committerlintao <lintao@rock-chips.com>
Tue, 18 Mar 2014 01:43:18 +0000 (09:43 +0800)
    We find some SDIO devices(especially Wi-Fi) need to triger software
rescan flow instead of hardware interrupt routine comfirmed by MMC spec.
Pls refer to the comments ahead of function for detailed.

drivers/mmc/core/host.c [changed mode: 0644->0755]

old mode 100644 (file)
new mode 100755 (executable)
index 2c886ae..8610b36
@@ -516,6 +516,7 @@ EXPORT_SYMBOL(mmc_alloc_host);
  *     prepared to start servicing requests before this function
  *     completes.
  */
+static struct mmc_host *primary_sdio_host;
 int mmc_add_host(struct mmc_host *host)
 {
        int err;
@@ -538,11 +539,15 @@ int mmc_add_host(struct mmc_host *host)
        if (!(host->pm_flags & MMC_PM_IGNORE_PM_NOTIFY))
                register_pm_notifier(&host->pm_notify);
 
+    if(host->restrict_caps & RESTRICT_CARD_TYPE_SDIO) 
+        primary_sdio_host = host;
+        
        return 0;
 }
 
 EXPORT_SYMBOL(mmc_add_host);
 
+
 /**
  *     mmc_remove_host - remove host hardware
  *     @host: mmc host
@@ -588,3 +593,36 @@ void mmc_free_host(struct mmc_host *host)
 }
 
 EXPORT_SYMBOL(mmc_free_host);
+
+/**
+ *     mmc_host_rescan - triger software rescan flow
+ *     @host: mmc host
+ *
+ *     rescan slot attach in the assigned host.
+ *     If @host is NULL, default rescan primary_sdio_host
+ *  saved by mmc_add_host().
+ *  OR, rescan host from argument.
+ *
+ */
+int mmc_host_rescan(struct mmc_host *host)
+{
+    if(NULL != primary_sdio_host){
+        if(!host)
+            host = primary_sdio_host;
+        else 
+            printk("mmc_host_rescan pass in host from argument!\n");
+    }
+    else{
+        printk("%s: host isn't  initialization successfully.\n",
+                mmc_hostname(host));
+        return -ENOMEDIUM;
+    }
+
+    printk("%s:mmc host rescan start!\n", mmc_hostname(host));
+                              
+    mmc_detect_change(host, msecs_to_jiffies(10));
+
+    return 0;
+}
+EXPORT_SYSMBOL(mmc_host_rescan);
+