mmc: block: fix boot partition switch error path
authorAdrian Hunter <adrian.hunter@intel.com>
Fri, 23 Sep 2011 09:48:20 +0000 (12:48 +0300)
committerChris Ball <cjb@laptop.org>
Wed, 26 Oct 2011 20:32:14 +0000 (16:32 -0400)
In the case of a switch error, do not update partition config as though
the switch succeeded, and ensure blk_end_request is called on the
failed request.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Acked-by: Andrei Warkentin <andrey.warkentin@gmail.com>
Signed-off-by: Chris Ball <cjb@laptop.org>
drivers/mmc/card/block.c

index 66c7596c55468e3836668be39561afed55cab3dc..d7eb2c082336056359719e0e0814934493d1b12b 100644 (file)
@@ -447,18 +447,23 @@ static inline int mmc_blk_part_switch(struct mmc_card *card,
 {
        int ret;
        struct mmc_blk_data *main_md = mmc_get_drvdata(card);
+
        if (main_md->part_curr == md->part_type)
                return 0;
 
        if (mmc_card_mmc(card)) {
-               card->ext_csd.part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK;
-               card->ext_csd.part_config |= md->part_type;
+               u8 part_config = card->ext_csd.part_config;
+
+               part_config &= ~EXT_CSD_PART_CONFIG_ACC_MASK;
+               part_config |= md->part_type;
 
                ret = mmc_switch(card, EXT_CSD_CMD_SET_NORMAL,
-                                EXT_CSD_PART_CONFIG, card->ext_csd.part_config,
+                                EXT_CSD_PART_CONFIG, part_config,
                                 card->ext_csd.part_time);
                if (ret)
                        return ret;
+
+               card->ext_csd.part_config = part_config;
        }
 
        main_md->part_curr = md->part_type;
@@ -1273,6 +1278,11 @@ static int mmc_blk_issue_rq(struct mmc_queue *mq, struct request *req)
 
        ret = mmc_blk_part_switch(card, md);
        if (ret) {
+               if (req) {
+                       spin_lock_irq(&md->lock);
+                       __blk_end_request_all(req, -EIO);
+                       spin_unlock_irq(&md->lock);
+               }
                ret = 0;
                goto out;
        }