From c9aa0019f087718fc1b2f6aec9df5eccd25d2ad0 Mon Sep 17 00:00:00 2001 From: Ulf Hansson Date: Mon, 6 Feb 2012 10:42:39 +0100 Subject: [PATCH] --- yaml --- r: 297331 b: refs/heads/master c: f0cc9cf99326926fd76f77645c48d16d647802eb h: refs/heads/master i: 297329: 76c22c92b16e03418008c347d46354efcc798aef 297327: 804be50e83f9bf196c43c0800e771cee6986fe6e v: v3 --- [refs] | 2 +- trunk/drivers/mmc/core/core.c | 24 +++++++++++++++++++++--- trunk/include/linux/mmc/host.h | 1 + 3 files changed, 23 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 16bf9498a9be..6f22f7d61763 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 885c3e800cf99db3391247776bfa2d262b21a72b +refs/heads/master: f0cc9cf99326926fd76f77645c48d16d647802eb diff --git a/trunk/drivers/mmc/core/core.c b/trunk/drivers/mmc/core/core.c index faa0af10d334..436409f7f7bd 100644 --- a/trunk/drivers/mmc/core/core.c +++ b/trunk/drivers/mmc/core/core.c @@ -2121,18 +2121,36 @@ int _mmc_detect_card_removed(struct mmc_host *host) int mmc_detect_card_removed(struct mmc_host *host) { struct mmc_card *card = host->card; + int ret; WARN_ON(!host->claimed); + + if (!card) + return 1; + + ret = mmc_card_removed(card); /* * The card will be considered unchanged unless we have been asked to * detect a change or host requires polling to provide card detection. */ - if (card && !host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL)) - return mmc_card_removed(card); + if (!host->detect_change && !(host->caps & MMC_CAP_NEEDS_POLL) && + !(host->caps2 & MMC_CAP2_DETECT_ON_ERR)) + return ret; host->detect_change = 0; + if (!ret) { + ret = _mmc_detect_card_removed(host); + if (ret && (host->caps2 & MMC_CAP2_DETECT_ON_ERR)) { + /* + * Schedule a detect work as soon as possible to let a + * rescan handle the card removal. + */ + cancel_delayed_work(&host->detect); + mmc_detect_change(host, 0); + } + } - return _mmc_detect_card_removed(host); + return ret; } EXPORT_SYMBOL(mmc_detect_card_removed); diff --git a/trunk/include/linux/mmc/host.h b/trunk/include/linux/mmc/host.h index ee2b0363c040..d1d3743fde90 100644 --- a/trunk/include/linux/mmc/host.h +++ b/trunk/include/linux/mmc/host.h @@ -258,6 +258,7 @@ struct mmc_host { #define MMC_CAP2_HS200 (MMC_CAP2_HS200_1_8V_SDR | \ MMC_CAP2_HS200_1_2V_SDR) #define MMC_CAP2_BROKEN_VOLTAGE (1 << 7) /* Use the broken voltage */ +#define MMC_CAP2_DETECT_ON_ERR (1 << 8) /* On I/O err check card removal */ mmc_pm_flag_t pm_caps; /* supported pm features */ unsigned int power_notify_type;