diff mbox series

[v2,01/11] mmc: core: Add helper function to indicate if SDIO IRQs is enabled

Message ID 20190908101236.2802-2-ulf.hansson@linaro.org
State New
Headers show
Series mmc: core: PM fixes/improvements for SDIO IRQs | expand

Commit Message

Ulf Hansson Sept. 8, 2019, 10:12 a.m. UTC
To avoid each host driver supporting SDIO IRQs, from keeping track
internally about if SDIO IRQs has been claimed, let's introduce a common
helper function, sdio_irq_claimed().

The function returns true if SDIO IRQs are claimed, via using the
information about the number of claimed irqs. This is safe, even without
any locks, as long as the helper function is called only from
runtime/system suspend callbacks of the host driver.

Tested-by: Matthias Kaehlcke <mka@chromium.org>

Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

---

Changes in v2:
	- Renamed function to sdio_irq_claimed().

---
 include/linux/mmc/host.h | 9 +++++++++
 1 file changed, 9 insertions(+)

-- 
2.17.1

Comments

Douglas Anderson Sept. 9, 2019, 10:32 p.m. UTC | #1
Hi,

On Sun, Sep 8, 2019 at 3:12 AM Ulf Hansson <ulf.hansson@linaro.org> wrote:
>

> To avoid each host driver supporting SDIO IRQs, from keeping track

> internally about if SDIO IRQs has been claimed, let's introduce a common

> helper function, sdio_irq_claimed().

>

> The function returns true if SDIO IRQs are claimed, via using the

> information about the number of claimed irqs. This is safe, even without

> any locks, as long as the helper function is called only from

> runtime/system suspend callbacks of the host driver.

>

> Tested-by: Matthias Kaehlcke <mka@chromium.org>

> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

> ---

>

> Changes in v2:

>         - Renamed function to sdio_irq_claimed().

>

> ---

>  include/linux/mmc/host.h | 9 +++++++++

>  1 file changed, 9 insertions(+)


Reviewed-by: Douglas Anderson <dianders@chromium.org>
diff mbox series

Patch

diff --git a/include/linux/mmc/host.h b/include/linux/mmc/host.h
index 4a351cb7f20f..a9d52a4d5041 100644
--- a/include/linux/mmc/host.h
+++ b/include/linux/mmc/host.h
@@ -493,6 +493,15 @@  void mmc_command_done(struct mmc_host *host, struct mmc_request *mrq);
 
 void mmc_cqe_request_done(struct mmc_host *host, struct mmc_request *mrq);
 
+/*
+ * May be called from host driver's system/runtime suspend/resume callbacks,
+ * to know if SDIO IRQs has been claimed.
+*/
+static inline bool sdio_irq_claimed(struct mmc_host *host)
+{
+	return host->sdio_irqs > 0;
+}
+
 static inline void mmc_signal_sdio_irq(struct mmc_host *host)
 {
 	host->ops->enable_sdio_irq(host, 0);