]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - drivers/mmc/core/mmc.c
mmc: Don't hold lock when releasing an added card
[mv-sheeva.git] / drivers / mmc / core / mmc.c
index e4371555160a77364eabdc4c2f0c95436dbe2ea5..cd0c6b246feda2777c4ffc931bbbfa7091847955 100644 (file)
@@ -1,5 +1,5 @@
 /*
- *  linux/drivers/mmc/mmc.c
+ *  linux/drivers/mmc/core/mmc.c
  *
  *  Copyright (C) 2003-2004 Russell King, All Rights Reserved.
  *  Copyright (C) 2005-2007 Pierre Ossman, All Rights Reserved.
@@ -237,7 +237,7 @@ out:
  * In the case of a resume, "curcard" will contain the card
  * we're trying to reinitialise.
  */
-static int mmc_sd_init_card(struct mmc_host *host, u32 ocr,
+static int mmc_init_card(struct mmc_host *host, u32 ocr,
        struct mmc_card *oldcard)
 {
        struct mmc_card *card;
@@ -499,14 +499,17 @@ static void mmc_resume(struct mmc_host *host)
        BUG_ON(!host->card);
 
        mmc_claim_host(host);
+       err = mmc_init_card(host, host->ocr, host->card);
+       mmc_release_host(host);
 
-       err = mmc_sd_init_card(host, host->ocr, host->card);
        if (err != MMC_ERR_NONE) {
                mmc_remove(host);
+
+               mmc_claim_host(host);
                mmc_detach_bus(host);
+               mmc_release_host(host);
        }
 
-       mmc_release_host(host);
 }
 
 #else
@@ -559,7 +562,7 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
        /*
         * Detect and init the card.
         */
-       err = mmc_sd_init_card(host, host->ocr, NULL);
+       err = mmc_init_card(host, host->ocr, NULL);
        if (err != MMC_ERR_NONE)
                goto err;
 
@@ -567,14 +570,14 @@ int mmc_attach_mmc(struct mmc_host *host, u32 ocr)
 
        err = mmc_add_card(host->card);
        if (err)
-               goto reclaim_host;
+               goto remove_card;
 
        return 0;
 
-reclaim_host:
-       mmc_claim_host(host);
+remove_card:
        mmc_remove_card(host->card);
        host->card = NULL;
+       mmc_claim_host(host);
 err:
        mmc_detach_bus(host);
        mmc_release_host(host);