OSDN Git Service

mmc: spi: Fix card detection during probe
authorJonathan Neuschäfer <j.neuschaefer@gmx.net>
Sun, 10 Feb 2019 17:31:07 +0000 (18:31 +0100)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 25 Feb 2019 14:40:36 +0000 (15:40 +0100)
commitc9bd505dbd9d3dc80c496f88eafe70affdcf1ba6
tree37340d6ee1c590fa278851b75453f3a0e78a36a1
parent5908e6b738e3357af42c10e1183753c70a0117a9
mmc: spi: Fix card detection during probe

When using the mmc_spi driver with a card-detect pin, I noticed that the
card was not detected immediately after probe, but only after it was
unplugged and plugged back in (and the CD IRQ fired).

The call tree looks something like this:

mmc_spi_probe
  mmc_add_host
    mmc_start_host
      _mmc_detect_change
        mmc_schedule_delayed_work(&host->detect, 0)
          mmc_rescan
            host->bus_ops->detect(host)
              mmc_detect
                _mmc_detect_card_removed
                  host->ops->get_cd(host)
                    mmc_gpio_get_cd -> -ENOSYS (ctx->cd_gpio not set)
  mmc_gpiod_request_cd
    ctx->cd_gpio = desc

To fix this issue, call mmc_detect_change after the card-detect GPIO/IRQ
is registered.

Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Cc: stable@vger.kernel.org
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/mmc_spi.c