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

mmc: slot-gpio: Add a function to enable/disable card detect IRQ wakeup

Commit 03dbaa04a2e5 ("mmc: slot-gpio: Add support to enable irq wake on
cd_irq") enabled wakeup at initialization. However drivers may wish to
enable and disable based on different criteria. Add a helper function
mmc_gpio_set_cd_wake() to make it easy for drivers to do that.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Adrian Hunter and committed by
Ulf Hansson
36f1d7e8 d5d568fa

+23 -2
+1 -2
drivers/mmc/core/core.c
··· 2655 2655 void mmc_stop_host(struct mmc_host *host) 2656 2656 { 2657 2657 if (host->slot.cd_irq >= 0) { 2658 - if (host->slot.cd_wake_enabled) 2659 - disable_irq_wake(host->slot.cd_irq); 2658 + mmc_gpio_set_cd_wake(host, false); 2660 2659 disable_irq(host->slot.cd_irq); 2661 2660 } 2662 2661
+21
drivers/mmc/core/slot-gpio.c
··· 154 154 } 155 155 EXPORT_SYMBOL(mmc_gpiod_request_cd_irq); 156 156 157 + int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on) 158 + { 159 + int ret = 0; 160 + 161 + if (!(host->caps & MMC_CAP_CD_WAKE) || 162 + host->slot.cd_irq < 0 || 163 + on == host->slot.cd_wake_enabled) 164 + return 0; 165 + 166 + if (on) { 167 + ret = enable_irq_wake(host->slot.cd_irq); 168 + host->slot.cd_wake_enabled = !ret; 169 + } else { 170 + disable_irq_wake(host->slot.cd_irq); 171 + host->slot.cd_wake_enabled = false; 172 + } 173 + 174 + return ret; 175 + } 176 + EXPORT_SYMBOL(mmc_gpio_set_cd_wake); 177 + 157 178 /* Register an alternate interrupt service routine for 158 179 * the card-detect GPIO. 159 180 */
+1
include/linux/mmc/slot-gpio.h
··· 31 31 unsigned int debounce, bool *gpio_invert); 32 32 void mmc_gpio_set_cd_isr(struct mmc_host *host, 33 33 irqreturn_t (*isr)(int irq, void *dev_id)); 34 + int mmc_gpio_set_cd_wake(struct mmc_host *host, bool on); 34 35 void mmc_gpiod_request_cd_irq(struct mmc_host *host); 35 36 bool mmc_can_gpio_cd(struct mmc_host *host); 36 37 bool mmc_can_gpio_ro(struct mmc_host *host);