1 From c9bd505dbd9d3dc80c496f88eafe70affdcf1ba6 Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= <j.neuschaefer@gmx.net>
3 Date: Sun, 10 Feb 2019 18:31:07 +0100
4 Subject: mmc: spi: Fix card detection during probe
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
9 From: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
11 commit c9bd505dbd9d3dc80c496f88eafe70affdcf1ba6 upstream.
13 When using the mmc_spi driver with a card-detect pin, I noticed that the
14 card was not detected immediately after probe, but only after it was
15 unplugged and plugged back in (and the CD IRQ fired).
17 The call tree looks something like this:
23 mmc_schedule_delayed_work(&host->detect, 0)
25 host->bus_ops->detect(host)
27 _mmc_detect_card_removed
28 host->ops->get_cd(host)
29 mmc_gpio_get_cd -> -ENOSYS (ctx->cd_gpio not set)
33 To fix this issue, call mmc_detect_change after the card-detect GPIO/IRQ
36 Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
37 Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
38 Cc: stable@vger.kernel.org
39 Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
40 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
43 drivers/mmc/host/mmc_spi.c | 1 +
44 1 file changed, 1 insertion(+)
46 --- a/drivers/mmc/host/mmc_spi.c
47 +++ b/drivers/mmc/host/mmc_spi.c
48 @@ -1450,6 +1450,7 @@ static int mmc_spi_probe(struct spi_devi
49 mmc->caps &= ~MMC_CAP_NEEDS_POLL;
50 mmc_gpiod_request_cd_irq(mmc);
52 + mmc_detect_change(mmc, 0);
54 if (host->pdata && host->pdata->flags & MMC_SPI_USE_RO_GPIO) {