diff options
author | Sujit Reddy Thumma <sthumma at> | 2011-11-18 22:39:30 -0600 |
---|---|---|
committer | Ziyann <jaraidaniel@gmail.com> | 2014-10-01 12:56:09 +0200 |
commit | 5f88ba19294cf7c5a3d21dfd495161b8a9e34b28 (patch) | |
tree | 0fa3728400518ab94902f4ec1d0b9b262e16c06e | |
parent | 6401c170173b2aec3cc405dd936547488b964471 (diff) | |
download | kernel_samsung_tuna-5f88ba19294cf7c5a3d21dfd495161b8a9e34b28.zip kernel_samsung_tuna-5f88ba19294cf7c5a3d21dfd495161b8a9e34b28.tar.gz kernel_samsung_tuna-5f88ba19294cf7c5a3d21dfd495161b8a9e34b28.tar.bz2 |
mmc: core: Kill block requests if card is removed
Kill block requests when the host knows that the card is
removed from the slot and is sure that subsequent requests
are bound to fail. Do this silently so that the block
layer doesn't output unnecessary error messages.
This patch implements suggestion from Adrian Hunter,
http://thread.gmane.org/gmane.linux.kernel.mmc/2714/focus=3474
Change-Id: I146299b4acbcce95f9cfac114ee3feb56d1a13bd
Signed-off-by: Sujit Reddy Thumma <sthumma <at> codeaurora.org>
Signed-off-by: David Taylor <x0158378@ti.com>
-rw-r--r-- | drivers/mmc/card/queue.c | 5 | ||||
-rw-r--r-- | drivers/mmc/core/bus.c | 2 | ||||
-rw-r--r-- | include/linux/mmc/card.h | 3 |
3 files changed, 10 insertions, 0 deletions
diff --git a/drivers/mmc/card/queue.c b/drivers/mmc/card/queue.c index 6413afa..34b9070 100644 --- a/drivers/mmc/card/queue.c +++ b/drivers/mmc/card/queue.c @@ -29,6 +29,8 @@ */ static int mmc_prep_request(struct request_queue *q, struct request *req) { + struct mmc_queue *mq = q->queuedata; + /* * We only like normal block requests and discards. */ @@ -37,6 +39,9 @@ static int mmc_prep_request(struct request_queue *q, struct request *req) return BLKPREP_KILL; } + if (mq && mq->card && !mmc_card_inserted(mq->card)) + return BLKPREP_KILL; + req->cmd_flags |= REQ_DONTPREP; return BLKPREP_OK; diff --git a/drivers/mmc/core/bus.c b/drivers/mmc/core/bus.c index e07d6c9..44191b1 100644 --- a/drivers/mmc/core/bus.c +++ b/drivers/mmc/core/bus.c @@ -298,6 +298,7 @@ int mmc_add_card(struct mmc_card *card) mmc_card_ddr_mode(card) ? "DDR " : "", type, card->rca); } + mmc_card_set_inserted(card); #ifdef CONFIG_DEBUG_FS mmc_add_card_debugfs(card); @@ -330,6 +331,7 @@ void mmc_remove_card(struct mmc_card *card) printk(KERN_INFO "%s: card %04x removed\n", mmc_hostname(card->host), card->rca); } + card->state &= ~MMC_STATE_INSERTED; device_del(&card->dev); } diff --git a/include/linux/mmc/card.h b/include/linux/mmc/card.h index 197178a..dfd13df 100644 --- a/include/linux/mmc/card.h +++ b/include/linux/mmc/card.h @@ -177,6 +177,7 @@ struct mmc_card { #define MMC_STATE_HIGHSPEED_DDR (1<<4) /* card is in high speed mode */ #define MMC_STATE_ULTRAHIGHSPEED (1<<5) /* card is in ultra high speed mode */ #define MMC_CARD_SDXC (1<<6) /* card is SDXC */ +#define MMC_STATE_INSERTED (1<<7) /* card present in the slot */ unsigned int quirks; /* card quirks */ #define MMC_QUIRK_LENIENT_FN0 (1<<0) /* allow SDIO FN0 writes outside of the VS CCCR range */ #define MMC_QUIRK_BLKSZ_FOR_BYTE_MODE (1<<1) /* use func->cur_blksize */ @@ -309,6 +310,7 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) #define mmc_card_sdio(c) ((c)->type == MMC_TYPE_SDIO) #define mmc_card_present(c) ((c)->state & MMC_STATE_PRESENT) +#define mmc_card_inserted(c) ((c)->state & MMC_STATE_INSERTED) #define mmc_card_readonly(c) ((c)->state & MMC_STATE_READONLY) #define mmc_card_highspeed(c) ((c)->state & MMC_STATE_HIGHSPEED) #define mmc_card_blockaddr(c) ((c)->state & MMC_STATE_BLOCKADDR) @@ -317,6 +319,7 @@ static inline void __maybe_unused remove_quirk(struct mmc_card *card, int data) #define mmc_card_ext_capacity(c) ((c)->state & MMC_CARD_SDXC) #define mmc_card_set_present(c) ((c)->state |= MMC_STATE_PRESENT) +#define mmc_card_set_inserted(c) ((c)->state |= MMC_STATE_INSERTED) #define mmc_card_set_readonly(c) ((c)->state |= MMC_STATE_READONLY) #define mmc_card_set_highspeed(c) ((c)->state |= MMC_STATE_HIGHSPEED) #define mmc_card_set_blockaddr(c) ((c)->state |= MMC_STATE_BLOCKADDR) |