Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mmc: mxs: fix card detection function for broken card detect

Return -ENOSYS in get_cd if broken-cd is specified in the device tree.

Commit a91fe279ae75 (mmc: mxs: use standard flag for broken card
detection) sets MMC_CAP_NEEDS_POLL when broken-cd is specified. This
driver sets this flag unconditionally as it does not support a card
detect interrupt. Instead, broken-cd means that there is no card detect
signal connected.

The mmc core checks the get_cd function return value to determine if a
card is present. Only for a non-zero return value it will attempt to
initialize the card. So retuning -ENOSYS will allow the card to be
initialized.

For comparison, mmc_gpio_get_cd in slot-gpio.c also returns -ENOSYS if
the card detect GPIO is not valid.

Signed-off-by: Daniel Willmann <daniel@totalueberwachung.de>
Acked-by: Sascha Hauer <s.hauer@pengutronix.de>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Chris Ball <chris@printf.net>

authored by

Daniel Willmann and committed by
Chris Ball
91769986 1acee84b

+7
+7
drivers/mmc/host/mxs-mmc.c
··· 70 70 unsigned char bus_width; 71 71 spinlock_t lock; 72 72 int sdio_irq_en; 73 + bool broken_cd; 73 74 }; 74 75 75 76 static int mxs_mmc_get_cd(struct mmc_host *mmc) ··· 78 77 struct mxs_mmc_host *host = mmc_priv(mmc); 79 78 struct mxs_ssp *ssp = &host->ssp; 80 79 int present, ret; 80 + 81 + if (host->broken_cd) 82 + return -ENOSYS; 81 83 82 84 ret = mmc_gpio_get_cd(mmc); 83 85 if (ret >= 0) ··· 572 568 { 573 569 const struct of_device_id *of_id = 574 570 of_match_device(mxs_mmc_dt_ids, &pdev->dev); 571 + struct device_node *np = pdev->dev.of_node; 575 572 struct mxs_mmc_host *host; 576 573 struct mmc_host *mmc; 577 574 struct resource *iores; ··· 638 633 mmc->ops = &mxs_mmc_ops; 639 634 mmc->caps = MMC_CAP_SD_HIGHSPEED | MMC_CAP_MMC_HIGHSPEED | 640 635 MMC_CAP_SDIO_IRQ | MMC_CAP_NEEDS_POLL; 636 + 637 + host->broken_cd = of_property_read_bool(np, "broken-cd"); 641 638 642 639 mmc->f_min = 400000; 643 640 mmc->f_max = 288000000;