]> asedeno.scripts.mit.edu Git - linux.git/blobdiff - drivers/mmc/core/slot-gpio.c
mmc: sdhci-pci: Respect PM flags when enabling card detect GPIO IRQ wakeup
[linux.git] / drivers / mmc / core / slot-gpio.c
index 3698b05760098d7628122a2d4df81c9cb2cdcd9b..31f7dbb1566873a4e05ae336c3c602fcf0f53c53 100644 (file)
@@ -149,11 +149,30 @@ void mmc_gpiod_request_cd_irq(struct mmc_host *host)
 
        if (irq < 0)
                host->caps |= MMC_CAP_NEEDS_POLL;
-       else if ((host->caps & MMC_CAP_CD_WAKE) && !enable_irq_wake(irq))
-               host->slot.cd_wake_enabled = true;
 }
 EXPORT_SYMBOL(mmc_gpiod_request_cd_irq);
 
+int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on)
+{
+       int ret = 0;
+
+       if (!(host->caps & MMC_CAP_CD_WAKE) ||
+           host->slot.cd_irq < 0 ||
+           on == host->slot.cd_wake_enabled)
+               return 0;
+
+       if (on) {
+               ret = enable_irq_wake(host->slot.cd_irq);
+               host->slot.cd_wake_enabled = !ret;
+       } else {
+               disable_irq_wake(host->slot.cd_irq);
+               host->slot.cd_wake_enabled = false;
+       }
+
+       return ret;
+}
+EXPORT_SYMBOL(mmc_gpio_set_cd_wake);
+
 /* Register an alternate interrupt service routine for
  * the card-detect GPIO.
  */