mmc: sdhci: add function get_cd
PATCH v2 2/2 mmc: sdhci: add function get_cd
1. mmc_rescan will call get_cd to know whether the card is present before mmc_rescan_try_freq to avoid useless trials during card removal or start host is called when card is not present.
2. get_cd need to be checked to resolve slow card removal issue.
--- drivers/mmc/host/sdhci.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+)
drivers/mmc/host/sdhci.c +29 -0
@@ -1581,6 +1581,34 @@ static void sdhci_set_ios(struct mmc_host *mmc, struct mmc_ios *ios)sdhci_runtime_pm_put (host); } +static int sdhci_do_get_cd (struct sdhci_host *host) +{ +int gpio_cd =mmc_gpio_get_cd (host->mmc); + +if (host->flags &SDHCI_DEVICE_DEAD ) +return 0 ; +/* Try slot gpio detect first */ +if (!IS_ERR_VALUE (gpio_cd)) +return !!gpio_cd; +/* If polling/nonremovable, assume that the card is always present. */ +if ((host->quirks &SDHCI_QUIRK_BROKEN_CARD_DETECTION ) || + (host->mmc->caps &MMC_CAP_NONREMOVABLE )) +return 1 ; +/* Host native card detect */ +return !!(sdhci_readl (host,SDHCI_PRESENT_STATE ) &SDHCI_CARD_PRESENT ); +} + +static int sdhci_get_cd (struct mmc_host *mmc) +{ +struct sdhci_host *host =mmc_priv (mmc); +int ret; + +sdhci_runtime_pm_get (host); + ret =sdhci_do_get_cd (host); +sdhci_runtime_pm_put (host); +return ret; +} +static int sdhci_check_ro (struct sdhci_host *host) {unsigned long flags;
@@ -2038,6 +2066,7 @@ static void sdhci_card_event(struct mmc_host *mmc)static const struct mmc_host_ops sdhci_ops = { .request = sdhci_request, .set_ios = sdhci_set_ios, + .get_cd = sdhci_get_cd, .get_ro = sdhci_get_ro, .hw_reset = sdhci_hw_reset, .enable_sdio_irq = sdhci_enable_sdio_irq,
Signature · 1 line
1.7.9.5
Quoted 6 lines · Kevin Liu
1.
mmc_rescanwill callget_cdto know whether the card is present beforemmc_rescan_try_freqto avoid useless trials during card removal or start host is called when card is not present.
2.get_cdneed to be checked to resolve slow card removal issue.Signed-off-by Kevin Liu <[email protected]>
Lookin' good!
Yours,
Linus Walleij
2013/3/1 Linus Walleij <[email protected]>:
Quoted 7 lines · Kevin Liu
Quoted 6 lines
1.
mmc_rescanwill callget_cdto know whether the card is present beforemmc_rescan_try_freqto avoid useless trials during card removal or start host is called when card is not present.
2.get_cdneed to be checked to resolve slow card removal issue.
Quoted 5 lines
Quoted 1 line
Signed-off-by Kevin Liu <[email protected]>Lookin' good!
Reviewed-by Linus Walleij <[email protected]>
Linus,
Thanks for the review. Can you also help to review the latest v3? The only difference to v2 is swap the check sequence between gpio and cd-broken quirk.
Kevin
Quoted 2 lines
Yours,
Linus Walleij
Quoted 3 lines · Kevin Liu
Thanks for the review. Can you also help to review the latest v3? The only difference to v2 is swap the check sequence between gpio and cd-broken quirk.
Yes I saw that, please add my Reviewed-by.
Yours,
Linus Walleij