[MMC] Fix SD timeout calculation
[pandora-kernel.git] / drivers / mmc / mmc.c
index 1ca2c8b..c0c7ef2 100644 (file)
@@ -9,7 +9,6 @@
  * it under the terms of the GNU General Public License version 2 as
  * published by the Free Software Foundation.
  */
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/init.h>
 #include <linux/interrupt.h>
@@ -129,7 +128,7 @@ static void mmc_wait_done(struct mmc_request *mrq)
 
 int mmc_wait_for_req(struct mmc_host *host, struct mmc_request *mrq)
 {
-       DECLARE_COMPLETION(complete);
+       DECLARE_COMPLETION_ONSTACK(complete);
 
        mrq->done_data = &complete;
        mrq->done = mmc_wait_done;
@@ -913,6 +912,7 @@ static void mmc_read_scrs(struct mmc_host *host)
        struct mmc_request mrq;
        struct mmc_command cmd;
        struct mmc_data data;
+       unsigned int timeout_us;
 
        struct scatterlist sg;
 
@@ -948,9 +948,20 @@ static void mmc_read_scrs(struct mmc_host *host)
 
                memset(&data, 0, sizeof(struct mmc_data));
 
-               data.timeout_ns = card->csd.tacc_ns * 10;
-               data.timeout_clks = card->csd.tacc_clks * 10;
+               data.timeout_ns = card->csd.tacc_ns * 100;
+               data.timeout_clks = card->csd.tacc_clks * 100;
+
+               timeout_us = data.timeout_ns / 1000;
+               timeout_us += data.timeout_clks * 1000 /
+                       (host->ios.clock / 1000);
+
+               if (timeout_us > 100000) {
+                       data.timeout_ns = 100000000;
+                       data.timeout_clks = 0;
+               }
+
                data.blksz_bits = 3;
+               data.blksz = 1 << 3;
                data.blocks = 1;
                data.flags = MMC_DATA_READ;
                data.sg = &sg;